以下代码可以实现:<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> sr: TSearchRec;<br> FileAttrs: Integer;<br> Dir,FileName:string;<br>begin<br> Dir:='d:/temp/';<br> FileAttrs := 0;<br> FileAttrs := FileAttrs + faAnyFile;<br> if FindFirst(Dir+'*.*', FileAttrs, sr) = 0 then<br> begin<br> repeat<br> FileName:=Dir+sr.Name;<br> if FileDateToDateTime(sr.Time) < Now then<br> deletefile(FileName);<br> until FindNext(sr) <> 0;<br> FindClose(sr);<br> end;<br>end;<br>多谢miaofeng!