关于文件的操作

dqb8 2004-05-08 12:14:05
String filename="6169report"+DateToStr(Date())+".log";
if(!FileExists(filename))
{
FileCreate(filename);
}

int iFileHandle = FileOpen(filename, 2);
FileWrite(iFileHandle,"56780",5);// 写文件
FileClose(iFileHandle);

这段好象是覆盖写内容 我想追加写内容到文件 并且按行 。请给予小弟帮助 ,先谢了
...全文
38 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
JetKingLau 2004-05-08
  • 打赏
  • 举报
回复
int iFileHandle = -1;//文件句柄
if(!FileExists(filename))//文件不存在则创建
{
iFileHandle = FileCreate(filename);
}
else {//文件存在
iFileHandle = FileOpen(filename, fmOpenReadWrite);//以读写方式打开
FileSeek(iFileHandle, 0, 2);//指向文件末尾
}

FileWrite(iFileHandle, "\r\n", 2);//添加换行
FileWrite...//添加内容

FileClose(iFileHandle);//关闭

13,871

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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