问题:如何获取文件的日期
网上搜 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
尤其是最后一个,还提到:
|