procedure TFrm_Main.DeleteOutOfDayDBS(strSourcePath: string;Days:integer); var FindResult: integer; sr: TSearchRec; dt:TDateTime; begin dt:=Now; FindResult := FindFirst(strSourcePath + '*.mdb', faAnyFile - faDirectory - faHidden - faSysFile, sr); try while FindResult = NO_Error do //NO_Error=0, 當(dāng)FindResult=0時表示搜索成功 begin if dt-FileDateToDateTime(sr.Time)>Days then DeleteFile(strSourcePath + sr.Name); FindResult := FindNext(sr); //下一個文件 end; finally FindClose(sr); //關(guān)閉搜索集 end; end;
|
|