Delphi获取文件创建时间、文件最后修改时间


本文整理自网络,侵删。

 
procedure TForm1.Button1Click(Sender: TObject);//获取文件创建时间
var
  FileName: string;
  ti: Integer;
  dt: TDateTime;
begin
  FileName := 'D:\test\Test.txt';
  ti := FileAge(FileName);
  ShowMessage(IntToStr(ti));  //返回: 1030115371, 需要转换
  dt := FileDateToDateTime(ti);  //转换
  ShowMessage(DateTimeToStr(dt));  //2010-11-6 10:01:22
end;

procedure TForm1.Button2Click(Sender: TObject);//获取文件最后修改时间
  procedure DirectoryDateTimeInfo(const path : string) ;
  var
    sr : TSearchRec;
    modifiedTime : TDateTime; // 修改时间
  begin
    if sysUtils.FindFirst(path, faDirectory, sr) = 0 then
      modifiedTime := FileDateToDateTime(sr.Time) ; // 修改时间
    ShowMessage(Format('Last Modified Time: "%s"', [DateTimeToStr(modifiedTime)])) ;
    FindClose(sr) ;
   end;
begin
  DirectoryDateTimeInfo('D:\test\Test.txt');
end;

相关阅读 >>

Delphi injectmemexe

Delphi 图像旋转90° 反旋转90°

Delphi fdlocalsql使用方法

Delphi 截图函数screenshot

Delphi字符串内多个空格合为一个空格

Delphi源码简单的实现粘贴复制代码

Delphi adoquery 运用

Delphi��image存入读取mysql数据库

webbrowser部分用法

Delphi 获取适合微信使用的当前日期,以int64表示,是当前时间和1970-01-01 00:00:00之间的秒差

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



打赏

取消

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

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

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

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

评论

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