如何操作.dat类型的文件,急...(100分)

  • 主题发起人 paulannar
  • 开始时间
P

paulannar

Unregistered / Unconfirmed
GUEST, unregistred user!
我做了一个DLL库,其中有几个函数需要操作一个a.dat文件(同目录下)<br>首先检查这个文件是否存在,如果不存在则创建这个a.dat。<br>如果存在则向这个文件中写入三行数据(文本)。<br>请问我该怎么处理?最好给一个稍详细点儿的例子。<br>谢谢各位了!
 
检查这个文件是否存在,有函数FileExists<br>创建文件TFileStream.create(参数)<br>写文件TFileStream.writebuffer('aaa',sizeof(aaa))<br>你查查帮助,再试试
 
Procedure TestYouData;<br>&nbsp;Var<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _TmFl : Text;<br>&nbsp;Begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;If (FileExits('A.DAT')) Then Exit;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AssignFile(_TmFl,'A.DAT');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ReWrite(_TmFl);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WriteLn(_TmFl,'第1行');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WriteLn(_TmFl,'第2行');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;WriteLn(_TmFl,'第3行');<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CloseFile(_TmFl);<br>&nbsp;End;<br>
 
多人接受答案了。
 
顶部