关于保存文件的问题

johilion 2003-08-25 09:17:07
我想向c;\hello.txt中不断添加文本内容hello,请问应该如何添加?如下代码为什么实现不了望指教,谢谢...
CFile fileText;
CString str="hello";
if(fileText.Open("C:\\hello.txt",CFile::modeCreate+CFile::modeNoTruncate+CFile::modeWrite))
{
fileText.Write((LPCSTR)str,strlen(str));
fileText.Close();
}
...全文
46 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wanglh 2003-08-25
  • 打赏
  • 举报
回复
CFile fileText;
CString str="hello";
if(fileText.Open("C:\\hello.txt",CFile::modeCreate+CFile::modeNoTruncate+CFile::modeWrite))
{
fileText.SeekToEnd();
fileText.Write(str,str.GetLength());
fileText.Close();
}
zhouyong0371 2003-08-25
  • 打赏
  • 举报
回复
CFile fileText;
CString str="hello";
if(fileText.Open("C:\\hello.txt",CFile::modeCreate+CFile::modeNoTruncate+CFile::modeWrite))
{
fileText.SeekToEnd();
fileText.Write((LPCSTR)str,str.GetLength());
fileText.Close();
}
zhouyong0371 2003-08-25
  • 打赏
  • 举报
回复
CFile fileText;
CString str="hello";
if(fileText.Open("C:\\hello.txt",CFile::modeCreate+CFile::modeNoTruncate+CFile::modeWrite))
{
fileText.Write((LPCSTR)str,str.GetLength()); //这里
fileText.Close();
}

2,586

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 资源
社区管理员
  • 资源
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧