-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileOper.cpp
More file actions
64 lines (55 loc) · 1.17 KB
/
FileOper.cpp
File metadata and controls
64 lines (55 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// FileOper.cpp: implementation of the CFileOper class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "NotePad.h"
#include "FileOper.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFileOper::CFileOper()
{
}
CFileOper::~CFileOper()
{
}
void CFileOper::ReadFile(CMyLink &m_link,CString FilePathName)//读文件
{
CString line;
CStdioFile myFile;
if(myFile.Open(FilePathName,CStdioFile::modeRead))
{
while(myFile.ReadString(line))
{
line+="\r\n";
m_link.AddNode(line);
}
}else
{
AfxMessageBox(_T("文件打开错误!"));
}
myFile.Close();
}
void CFileOper::WriteFile(CMyLink &m_link,CString FilePathName)//写文件
{
int i;
CString line;
CStdioFile myFile;
if(myFile.Open(FilePathName,CStdioFile::modeCreate|CStdioFile::modeWrite))
{
for(i=0;i<m_link.GetLen();i++)
{
line = m_link.GetData(i);
myFile.WriteString(line);
}
myFile.Close();
}else
{
AfxMessageBox(_T("文件打开错误!"));
}
}