delphi写入txt


本文整理自网络,侵删。

 

unit WriteLog;

interface

Uses Windows,SysUtils;

function WriteTxt(strWrite:string):boolean;

implementation

function WriteTxt(strWrite:string):boolean;
var
  wLogFile: TextFile;
  DateTime: TDateTime;
  strTxtName,strContent: string;
begin
  DateTime:=now;
  strTxtName:=ExtractFilePath(paramstr(0))+FormatdateTime('yyyy-mm-dd',DateTime)+'.txt';
  AssignFile(wLogFile, strTxtName);
  if FileExists(strTxtName) then
    Append(wLogFile)
  else
  begin
    ReWrite(wLogFile);
  end;
  strContent:=FormatdateTime('tt',DateTime)+' '+strWrite;
  Writeln(wLogFile, strContent);
  CloseFile(wLogFile);

  Result:=true;
end;

end.

相关阅读 >>

Delphi 如何检测你的电脑日期或时间的变化

Delphi模拟文件拖拽

Delphi取得当前目录的上一级目录

Delphi 从网址链接中提取域名

Delphi ticon保存ico文件时失真的解决办法

Delphi idhttpserver的使用方法

Delphi中用socket解析域名获得ip地址

Delphi学习之资源文件dll的制作及使用

Delphi程序不受windows日期格式的影响

Delphi 提升Delphi 启动加载速度

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



打赏

取消

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

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

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

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

评论

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