如何删除一个非空文件夹(100分)

  • 主题发起人 主题发起人 LeeChange
  • 开始时间 开始时间
L

LeeChange

Unregistered / Unconfirmed
GUEST, unregistred user!
怎么样删除一个非空文件夹最快.(别对我说递归)<br>提供最快方法的人拿所有分
 
var<br>&nbsp; &nbsp;lsPath: string;<br>&nbsp; &nbsp;FileOp: TSHFileOpStruct;<br>begin<br>&nbsp; &nbsp; &nbsp; lsPath := 'c:/temp/';<br>&nbsp; &nbsp; &nbsp; //删除临时文件<br>&nbsp; &nbsp; &nbsp; with FileOp do begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Wnd := 0;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wFunc := FO_DELETE;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pFrom := PChar(lsPath &nbsp;+ '*.*' + #0); &nbsp; &nbsp; //取目录,与isFaq没有实际关系<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pTo := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fFlags := FOF_SILENT + FOF_NOCONFIRMATION ;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fAnyOperationsAborted := False;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;hNameMappings := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lpszProgressTitle := nil;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; SHFileOperation(FileOp);<br>&nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; RemoveDir(lsPath );<br>end;
 
k 兄<br>我觉得如果pfrom换成如下的模样会直接删除掉文件夹<br>而不用removedir这一句<br>pfrom:='c:/temp';<br>可能是这样.
 
多人接受答案了。
 
后退
顶部