//给分。。。<br>procedure DeleteDir(sDirectory: String);<br>//删除目录和目录下得所有文件和文件夹 <br>var <br> sr: TSearchRec; <br> sPath,sFile: String;<br>begin <br> //检查目录名后面是否有 '/' <br> if Copy(sDirectory,Length(sDirectory),1) <> '/' then <br> sPath := sDirectory + '/' <br> else <br> sPath := sDirectory; <br><br> //------------------------------------------------------------------ <br> if FindFirst(sPath+'*.*',faAnyFile, sr) = 0 then <br> begin <br> repeat <br> sFile:=Trim(sr.Name); <br> if sFile='.' then Continue; <br> if sFile='..' then Continue; <br><br> sFile:=sPath+sr.Name; <br> if (sr.Attr and faDirectory)<>0 then <br> DeleteDir(sFile) <br> else if (sr.Attr and faAnyFile) = sr.Attr then <br> DeleteFile(sFile); //删除文件 <br> until FindNext(sr) <> 0; <br> FindClose(sr); <br> end; <br> RemoveDir(sPath); <br> //------------------------------------------------------------------ <br>end;