关于txt写入信息后打开为0字节

johnlove9527 johnlove9527 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
RT,我新建了一个对话框,对话框中edit控件内输入数字后点击按钮写入一段数据进入txt内,但是我调试时候发现点击按钮后新建的txt为0字节。等于没写入。请教是什么原因。
代码如下:
CStdioFile file;
file.Open(pathtxt,CFile::modeCreate | CFile::modeWrite);
//存储时间文件数据
for(int i=0; i<2; i++)//num_mday
{
CString cs_temp="",cs_temp2="",cs_temp3="";
cs_temp="2014-0";
cs_temp2.Format("%d",num_stm);
cs_temp=cs_temp+cs_temp2;
cs_temp=cs_temp+"-";
cs_temp3.Format("%02d",i+1);
cs_temp=cs_temp+cs_temp3;
cs_temp=cs_temp+" 09";
file.WriteString(cs_temp);
file.WriteString("\n");
}
file.Close();
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
johnlove9527
VC/MFC 16,551 成员 421,605 内容