提供源碼, 可以搜尋指定目錄下的所有檔案(包含子目錄), 至於其它的, 你應有辦法完成<br>如果讀取檔案的存取時間, 可以讀取FileRec.FindData.ftCreationTime為創建時間;<br>FileRec.FindData.ftLastAccessTime為最後讀取時間;<br>FileRec.FindData.ftLastWriteTime為最後寫入時間<br>不過以上為系統檔案時間格式, 可用以下程式轉換為Delphi的TDateTime<br><br>function FileTimeToDateTime(const FileTime: _FILETIME): TDateTime;<br> var<br> SystemTime: TSystemTime;<br>begin<br> FileTimeToSystemTime(FileTime, SystemTime);<br> Result := SystemTimeToDateTime(SystemTime);<br>end;<br><br>function CheckSearch(ReturnCode: DWORD): boolean;<br>var<br> Error: EWin32Error;<br>begin<br> Case ReturnCode of<br> ERROR_SUCCESS: Result := True;<br> ERROR_FILE_NOT_FOUND, ERROR_NO_MORE_FILES, ERROR_PATH_NOT_FOUND: Result := False;<br> else begin<br> Error := EWin32Error.CreateResFmt(@SWin32Error, [ReturnCode,<br> SysErrorMessage(ReturnCode)]);<br> Error.ErrorCode := ReturnCode;<br> raise Error;<br> end;<br> end;<br>end;<br><br>procedure SearchFiles(SourcePath: string);<br><br> function AcceptFile(const FileName: string): boolean;<br> begin<br> Result := True; //用來判斷找到的檔案, 是否為想要圖形檔, 可以附檔名來判斷<br> end;<br><br> procedure SearchFile(Path: string);<br> var<br> sName: string;<br> FileRec: TSearchRec;<br> begin<br> Path := IncludeTrailingBackslash(Path);<br> if CheckSearch(FindFirst(Path+'*.*', faAnyFile, FileRec)) then<br> repeat<br> if ((FileRec.Attr and faDirectory) = faDirectory) then begin<br> if (FileRec.Name[1] <> '.') then SearchFile(Path + FileRec.Name);<br> end else begin<br> sName := Path + FileRec.Name;<br> if AcceptFile(sName) then <br> begin<br> //找到檔案, 做你想要處理<br> end;<br> end;<br> until not CheckSearch(FindNext(FileRec));<br> end;<br><br>begin<br> SearchFile(SourcePath);<br>end;