读文件的日期

问题:如何获取文件的日期

网上搜 Delphi+文件日期,获得的几个网页,内容都是互相转抄。

比如这篇:https://blog.csdn.net/l799623787/article/details/8029165

比如这篇:https://www.cnblogs.com/jieke/archive/2013/01/11/2855782.html

总之给出的方法是比较复杂的。

但如果搜索英语网页,则可以获得更加简单的结果。比如以下代码来自官方:https://edn.embarcadero.com/article/15541

function GetFileDate(TheFileName: string): string;
var
  FHandle: integer;
begin
  FHandle := FileOpen(TheFileName, 0);
  try
    Result := DateTimeToStr(FileDateToDateTime(FileGetDate(FHandle)));
  finally
    FileClose(FHandle);
  end;
end;

还有更简单的,uses System.SysUtils 以后,有这么一个函数:FileAge   一个函数搞定。

来自这里:https://stackoverflow.com/questions/144453/how-to-get-create-last-modified-dates-of-a-file-in-delphi

和这里:http://www.delphibasics.co.uk/RTL.asp?Name=FileAge

尤其是最后一个,还提到:

DateTimeToFileDate Convert a TDateTime value to a File date/time format
FileDateToDateTime Converts a file date/time format to a TDateTime value
FileSetDate Set the last modified date and time of a file
FileGetAttr Gets the attributes of a file
FileSetAttr Sets the attributes of a file
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值