各位大虾好!!!小弟想实现如何删除当前路径下不为空的目录,据小弟所知的只有能删除空目录的方法,不知道Delphi有没有提供删除非空目录的方法啊,请各位大虾指教一下,谢谢!!!
解决方案 »
- 还是流读写writebuffer问题
- http://9it.vicp.net 朋友做的BBS,大家帮忙捧捧场啊!
- 高手啊,,请帮我将这个C++原形转换成delphi的原形,谢谢拉
- 关于定义Record的问题
- 这种情况用什么条件分组打印? 内详
- 小女子有问题请教各位大侠
- Indy+FTP+REST+奇怪的令人搞不懂:等待高手指点迷津
- 请问如何得到当前系统菜单的宽度???
- tcp 外文文献
- 如何读文本文件中的网页地址?用delphi
- 怎样提取一个Exe文件的字符串资源?
- 这样写执行到Tradiobutton(findcomponent('rd1')).Checked:=true为什么总是报错呀,我是菜鸟,帮帮我
var
sr: TSearchRec;
begin
SourcePath:=IncludeTrailingPathDelimiter(SourcePath);
if FindFirst(SourcePath + '*.*', faAnyFile, sr) = 0 then
begin
repeat
DeleteFile(SourcePath + sr.Name);
until FindNext(sr) <> 0;
FindClose(sr);
RemoveDir(SourcePath);
end;
end;
var
vSHFileOpStruct: TSHFileOpStruct;
begin
FillChar(vSHFileOpStruct, SizeOf(vSHFileOpStruct), 0);
with vSHFileOpStruct do
begin
Wnd := Application.Handle;
wFunc := FO_DELETE;
pFrom := PChar(mSource + #0);
pTo := #0#0;
fFlags := FOF_NOCONFIRMATION+FOF_SILENT;
end;
Result := SHFileOperation(vSHFileOpStruct) = 0;
end; { DeleteDirectory }procedure TForm1.Button1Click(Sender: TObject);
begin
DeleteDirectory('C:\temp');
end;