批量删除目录和目录下得所有文件和文件夹
该日志由
samool 发表于 2007-10-09 12:08 PM
delphi代码
- procedure DeleteDir(sDirectory: String);
-
- var
- sr: TSearchRec;
- sPath,sFile: String;
- begin
-
- if Copy(sDirectory,Length(sDirectory),1) <> '\' then
- sPath := sDirectory + '\'
- else
- sPath := sDirectory;
-
- //------------------------------------------------------------------
- if FindFirst(sPath+'*.*',faAnyFile, sr) = 0 then
- begin
- repeat
- sFile:=Trim(sr.Name);
- if sFile='.' then Continue;
- if sFile='..' then Continue;
-
- sFile:=sPath+sr.Name;
- if (sr.Attr and faDirectory)<>0 then
- DeleteDir(sFile)
- else if (sr.Attr and faAnyFile) = sr.Attr then
- DeleteFile(sFile);
- until FindNext(sr) <> 0;
- FindClose(sr);
- end;
- RemoveDir(sPath);
-
- end;
相关文章: (最多只显示8条记)
发表评论:( 来了就留个脚印吧!你的参与是我最大的动力!)