写文件:
第一行写文件编码;
//1.定义全局变量
CStdioFile m_file;
//2.写入数据操作
//路径中需要带文件类型名称
char *path = "E:\\MySoftall\\MFC练习\\MFCRunLog\\test.txt";
m_file.Open(path,/*CFile::typeText|*/CFile::modeNoTruncate | CFile::modeCreate | CFile::modeReadWrite);
m_file.SeekToEnd();
m_file.WriteString(str);
m_file.Close();
//使用说明
//-----------------------------------------------
// CStdioFile写文件示例
// 实现功能:1.如果文件存在,在文件末尾添加内容
// 2.如果文件不存在,则创建文件并添加内容
//-----------------------------------------------
CString cstrFileFullPath = "D:\\test.txt";
// 判断文件是否存在,如果存在则去掉只读属性
if (PathFileExists(cstrFileFullPath) && !PathIsDirectory(cstrFileFullPath))
{
DWORD dwAttrs = GetFileAttributes(cstrFileFullPath);
if (dwAttrs != INVALID_FILE_ATTRIBUTES
&& (dwAttrs & FI