procedure TForm1.Button1Click(Sender:TObject);
var f:teztfile;<- 是不是打错了?
Currentpath:String;
begin
Currentpath := 'D:\LogFile';
if SetCurrentDir(Currentpath);//Cuurentpath是自定义的String类型
then if FileCreate('Log.txt')>0
then begin
Assign(f,'Log.txt');//用AssignFile
Append(f);//用FileWrite
Writeln(f,'Doday Is Testing');//省,由FileWrite实现
CloseFile(f);
end;
end;
var f:teztfile;<- 是不是打错了?
Currentpath:String;
begin
Currentpath := 'D:\LogFile';
if SetCurrentDir(Currentpath);//Cuurentpath是自定义的String类型
then if FileCreate('Log.txt')>0
then begin
Assign(f,'Log.txt');//用AssignFile
Append(f);//用FileWrite
Writeln(f,'Doday Is Testing');//省,由FileWrite实现
CloseFile(f);
end;
end;
解决方案 »
- 用delphi调用vc写的dll出错?
- 如何时使用线程实现idhttp.get
- 如何控制Dbgrid中的前两列不受水平滚动条的限制?
- [我只有10分了]超级难题!!!我用MySQL3.32.21b,其中有个表a要经常写数据进去,当数据到一定量,数据表就只能读不能写,怎么办啊?
- 100分求购delphi资料
- 如何创建一个虚拟内存表
- MessageBox的问题!!!!!应该是很简单,可是俺不会:(
- 小弟想做一个像foxmail那样动态字幕窗体,请问动态字幕如何实现,应该不是利用一个label控件吧!
- DRAG AND DROP在DELPHI中怎么用?
- 寻求大家帮助,做了一个p2p的软件,已接近完成,
- 如何实现,选择数据库中id值为最大的那条数据
- 怎样最高效地知道一个目录所占的字节数?
begin
AssignFile(f,'D:\logfile\log.txt');
Try
Append(f);
Except
ReWrite(f);
End;
Writeln(f,''Doday Is Testing');
CloseFile(f);
end;
var f:textfile;//teztfile;
Currentpath:String;
begin
Currentpath := 'D:\LogFile';
if SetCurrentDir(pChar(Currentpath))//;//Cuurentpath是自定义的String类型
then if FileCreate('Log.txt')>0
then begin
Assign(f,'Log.txt');
Append(f);
Writeln(f,'Doday Is Testing');
CloseFile(f);
end;
end;
Reset(F); //打开存在的文件,文件指针定在最上面,开始读或写文件
//ReWrite(F) 开始写一个文件,如果AssignFile分配的文件不存在,则创建,所以不用FileCreate
...
finally
CloseFile(F);
end;最后: FileCreate返回的是一个文件句柄资源,如果你不CloseHandle FileCreate返回的文件句柄的话,那用AssignFile,Writeln可能就会有问题,
你的问题可能就是出在这。