我想将这些属性的文件作为整数值.
尝试
function FileAge(const FileName: string; out FileDateTime: TDateTime): Boolean;
来自SysUtils.
Delphians倾向于喜欢FindFirst方法(SearchRec结构中有一些),但我建议使用Win32 API函数GetFileAttributesEx.
来自DSiWin32免费软件库:
function DSiFileTimeToDateTime(fileTime: TFileTime; var dateTime: TDateTime): boolean; var sysTime: TSystemTime; begin Result := FileTimeToSystemTime(fileTime, sysTime); if Result then dateTime := SystemTimeToDateTime(sysTime); end; { DSiFileTimeToDateTime } function DSiGetFileTimes(const fileName: string; var creationTime, lastAccessTime, lastModificationTime: TDateTime): boolean; var fileHandle : cardinal; fsCreationTime : TFileTime; fsLastAccessTime : TFileTime; fsLastModificationTime: TFileTime; begin Result := false; fileHandle := CreateFile(PChar(fileName), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, 0, 0); if fileHandle <> INVALID_HANDLE_VALUE then try Result := GetFileTime(fileHandle, @fsCreationTime, @fsLastAccessTime, @fsLastModificationTime) and DSiFileTimeToDateTime(fsCreationTime, creationTime) and DSiFileTimeToDateTime(fsLastAccessTime, lastAccessTime) and DSiFileTimeToDateTime(fsLastModificationTime, lastModificationTime); finally CloseHandle(fileHandle); end; end; { DSiGetFileTimes }