Delphi文本文件的写操作


本文整理自网络,侵删。

 

Delphi有关文本文件的操作,经整理后,我将其封装成了一个函数,
以方便以后的使用,访函数代码如下:

//将帐号信息写入文本文件函数
procedure TForm1.WriteUserToText(user:String; pass:String);
var
  txt:TextFile;
begin

//先判断一下文件是否存在, 不存在时就创建它
if not FileExists('C:\p.txt') then
begin
  Assignfile(txt,'c:\p.txt');  //指定文件路径
  rewrite(txt);               //创建并打开一个新文件(或覆盖原有文件)
  Closefile(txt);            //关闭打开的文件
end;

  AssignFile(txt,'C:\p.txt');
  Append(txt);                     //以追加的方式打开文件,指针到尾
  Writeln(txt,user+'--->'+pass);  //写文件
  CloseFile(txt);                //关闭打开的文件

end;
/////////////////////////////////////////////////////////////

相关阅读 >>

Delphi settimer 用法

Delphi gridpanel percent百分比设置

encryptit.pas

Delphi在case语句中使用字符串

Delphi adoquery查询用户是否存在

Delphi 字符串定界符

Delphi 字母大小写转换

Delphi 获取 cpu 使用率的单元

Delphi 选择文件夹对话框 (有新建文件夹按钮)修正版

Delphi 的tstringbuilder防止服务器内存碎片化

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...