posts - 0, comments - 77, trackbacks - 0, articles - 356
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

BCB写文本文件

Posted on 2006-05-12 15:02 semovy 阅读(1360) 评论(0)  编辑  收藏 所属分类: C++ Builder相关
void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{

int fileHandle = 0;
if(SaveDialog1->Execute())
{
if(FileExists(SaveDialog1->FileName))
{
 if(Application->MessageBoxA(\\\"该文件已经存在,是否替换?\\\",\\\"信息提示框\\\",MB_YESNO) == 6)
 {
fileHandle = FileCreate(SaveDialog1->FileName);
String str = \\\"第一列\\\\t\\\\t第二列\\\\t\\\\t第三列\\\\t\\\\t第四列\\\\t\\\\t第五列\\\\r\\\\n\\\";
FileWrite(fileHandle,str.c_str(), str.Length());
for(int i=0;i<10;i++)
FileWrite(fileHandle,str.c_str(), str.Length());
FileClose(fileHandle);
ShowMessage(\\\"OK\\\");
 }
else
{
 return;
}
 }
 else
 {
 fileHandle = FileCreate(SaveDialog1->FileName);
String str = \\\"第一列\\\\t\\\\t第二列\\\\t\\\\t第三列\\\\t\\\\t第四列\\\\t\\\\t第五列\\\\r\\\\n\\\";
FileWrite(fileHandle,str.c_str(), str.Length());
for(int i=0;i<10;i++)
FileWrite(fileHandle,str.c_str(), str.Length());
FileClose(fileHandle);
ShowMessage(\\\"OK\\\");
 }

}


只有注册用户登录后才能发表评论。


网站导航: