H
hubdog
Unregistered / Unconfirmed
GUEST, unregistred user!
正好有个人今天发信问我不用递归如何删除目录,我随手写的,就发这吧
使用shfileoperation函数恐怕是最简单的办法了吧?还有人有更简单的办法吗?
uses shellapi;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
Var
T:TSHFileOpStruct;
P:String;
begin
P:='d:/address';//这里改成你要删除的任意目录名
With Tdo
begin
Wnd:=0;
wFunc:=FO_DELETE;
pFrom:=Pchar(P);
pTo:=nil;
fFlags:=FOF_ALLOWUNDO+FOF_NOCONFIRMATION+FOF_NOERRORUI;//标志表明允许恢复,无须确认并不显示出错信息
hNameMappings:=nil;
lpszProgressTitle:='正在删除文件夹';
fAnyOperationsAborted:=False;
end;
SHFileOperation(T);
end;
使用shfileoperation函数恐怕是最简单的办法了吧?还有人有更简单的办法吗?
uses shellapi;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
Var
T:TSHFileOpStruct;
P:String;
begin
P:='d:/address';//这里改成你要删除的任意目录名
With Tdo
begin
Wnd:=0;
wFunc:=FO_DELETE;
pFrom:=Pchar(P);
pTo:=nil;
fFlags:=FOF_ALLOWUNDO+FOF_NOCONFIRMATION+FOF_NOERRORUI;//标志表明允许恢复,无须确认并不显示出错信息
hNameMappings:=nil;
lpszProgressTitle:='正在删除文件夹';
fAnyOperationsAborted:=False;
end;
SHFileOperation(T);
end;