如何按文件的修改日期获取指定目录下的文件 ( 积分: 100 )

  • 主题发起人 主题发起人 txj138
  • 开始时间 开始时间
T

txj138

Unregistered / Unconfirmed
GUEST, unregistred user!
近日要写一程序,从指定的目录里按修改日期来获取文件,不知道该如何实现,望各位高手指点下!
 
转帖
得到一个文件的创建日期,修改时
procedure TForm1.Button1Click(Sender: TObject);
var
FileOp : TOFStruct ;
FHandle : THandle ;
FInfo : TByHandleFileInformation ;
dtCreate,dtCreate2 : TSystemTime;
Temp:_FileTime;
begin
memo1.clear;

setlasterror(20);
FHandle:= openfile(pchar(edit1.text),FileOp ,OF_READ);
GetFileInformationByHandle(FHandle,FInfo);

memo1.Lines.Add('File Attributes : '+inttostr(FInfo.dwFileAttributes));


FileTimeToLocalFileTime(FInfo.ftCreationTime,Temp);
FileTimeToSystemTime(Temp,dtCreate);


memo1.Lines.Add('File Create Time : '
+inttostr(dtCreate.wYear)+'-'
+inttostr(dtCreate.wMonth)+'-'
+inttostr(dtCreate.wDay)+' '
+inttostr(dtCreate.wHour)+':'
+inttostr(dtCreate.wMinute)+':'
+inttostr(dtCreate.wSecond) );

FileTimeToLocalFileTime(FInfo.ftLastAccessTime,Temp);
FileTimeToSystemTime(Temp,dtCreate);


memo1.Lines.Add('File Last Access Time : '
+inttostr(dtCreate.wYear)+'-'
+inttostr(dtCreate.wMonth)+'-'
+inttostr(dtCreate.wDay)+' '
+inttostr(dtCreate.wHour)+':'
+inttostr(dtCreate.wMinute)+':'
+inttostr(dtCreate.wSecond) );

FileTimeToLocalFileTime(FInfo.ftLastWriteTime,Temp);
FileTimeToSystemTime(Temp,dtCreate);

memo1.Lines.Add('File Last Write Time : '
+inttostr(dtCreate.wYear)+'-'
+inttostr(dtCreate.wMonth)+'-'
+inttostr(dtCreate.wDay)+' '
+inttostr(dtCreate.wHour)+':'
+inttostr(dtCreate.wMinute)+':'
+inttostr(dtCreate.wSecond) );

memo1.Lines.Add('File Path and Name : '+FileOp.szPathName);

_lclose(FHandle);

end;
 
接受答案了.
 
后退
顶部