還有什麼方法可以刪除目錄(100分)

  • 主题发起人 主题发起人 gy131417
  • 开始时间 开始时间
G

gy131417

Unregistered / Unconfirmed
GUEST, unregistred user!
[:(]我用rmdir來刪除目錄,總是出現'I/O ERROR'請問各位大富翁還有沒不別的方法來實現,<br>給我一點建義。如何?
 
function DelDir(const Source:string): boolean;<br>var<br>&nbsp; fo: TSHFILEOPSTRUCT;<br>begin<br>&nbsp; FillChar(fo, SizeOf(fo), 0);<br>&nbsp; with fo do<br>&nbsp; begin<br>&nbsp; &nbsp; Wnd := 0;<br>&nbsp; &nbsp; wFunc := FO_DELETE;<br>&nbsp; &nbsp; pFrom := PChar(source+#0);<br>&nbsp; &nbsp; pTo := #0#0;<br>&nbsp; &nbsp; fFlags := FOF_NOCONFIRMATION+FOF_SILENT;//FOF_SILENT表示不出现对话框。<br>&nbsp; end;<br>&nbsp; Result := (SHFileOperation(fo) = 0);<br>end;<br>
 
在C盘建立tyn1目录,里面放几个文件 :<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; FileOpStruct :TSHFileOpStruct;<br>&nbsp; Buf1 :array [0..127] of Char;<br>&nbsp; Str1 :String;<br>begin<br>&nbsp; Str1 :='c:/tyn1';<br>&nbsp; FillChar(Buf1,SizeOf(Buf1),0);<br>&nbsp; StrPCopy(Buf1,Str1);<br>&nbsp; with FileOpStruct do<br>&nbsp; begin<br>&nbsp; &nbsp; Wnd :=Handle;<br>&nbsp; &nbsp; wFunc :=FO_DELETE;<br>&nbsp; &nbsp; pFrom :=@Buf1;<br>&nbsp; &nbsp; pTo :=nil;<br>&nbsp; &nbsp; fFlags :=FOF_SIMPLEPROGRESS;<br>&nbsp; &nbsp; fAnyOperationsAborted :=False;<br>&nbsp; &nbsp; hNameMappings :=nil;<br>&nbsp; &nbsp; lpszProgressTitle :='删除文件';<br>&nbsp; end;<br>&nbsp; SHFileOperation(FileOpStruct);<br>end;<br>记得添加ShellAPI单元!
 
利用DELTREE,<br>请参考 :<br>&nbsp; <br>&nbsp; http://www.delphibbs.com/delphibbs/dispq.asp?lid=429380<br><br>谢谢。
 
同:冰 原
 
用DeleteDirectory函数啊
 
和卷起千堆雪tyn的想法一样<br>其实不用向楼上几位写的那么复杂,只要<br><br>&nbsp; WinExec()<br><br>然后调用deltree.exe<br><br>呵呵,如果SYSTEM不支持DOS,那么就惨了。不过呢,这是一个很简单方法!
 
后退
顶部