procedure ZsDelPath(mDirName: string); { 删除指定路径 }
var
Sr: TSearchRec;
PathName: string;
K: Integer;
begin
PathName := mDirName + '\*.*';
K := FindFirst(PathName, faAnyFile, Sr);
while K = 0 do begin
if (Sr.Attr and faDirectory > 0) and (Pos(Sr.Name, '..') = 0) then begin
Sr.Attr := 16;
ZsDelPath(mDirName + '\' + Sr.Name);
end else if Pos(Sr.Name, '..') = 0 then begin
Sr.Attr := 0;
DeleteFile(PChar(mDirName + '\' + Sr.Name));
end;
K := FindNext(Sr);
end;
RmDir(mDirName);
end; { ZsDelPath }procedure TForm1.Button1Click(Sender: TObject);
begin
ZsDelPath('C:\Temp')
end;
var
Sr: TSearchRec;
PathName: string;
K: Integer;
begin
PathName := mDirName + '\*.*';
K := FindFirst(PathName, faAnyFile, Sr);
while K = 0 do begin
if (Sr.Attr and faDirectory > 0) and (Pos(Sr.Name, '..') = 0) then begin
Sr.Attr := 16;
ZsDelPath(mDirName + '\' + Sr.Name);
end else if Pos(Sr.Name, '..') = 0 then begin
Sr.Attr := 0;
DeleteFile(PChar(mDirName + '\' + Sr.Name));
end;
K := FindNext(Sr);
end;
RmDir(mDirName);
end; { ZsDelPath }procedure TForm1.Button1Click(Sender: TObject);
begin
ZsDelPath('C:\Temp')
end;
解决方案 »
- 将查询结果添加到数据库中遇到问题
- 下面这段代码是我找的,听说可以加载成rc(资源文件),就可以在vista上执行,并出现提示框.但小弟我不知如何做.请大家帮助.
- 修罗戏子进来拿分。
- 请帮忙把把下面vbScript的程序转化为DELPHI的,分不够在加
- 连接Database时出现Operation must be performed on the current session
- 用ADO删除出错
- 已知窗口句柄,如何取得窗口的图标(ICON)的句柄?(还附加一问)
- 怎么样设置一个目录的属性,比如只读,隐藏。请指教!谢谢!
- 在isapi中,如何可分解读取图像和文字混合上传的request.content值??
- 用delphi做的数据库中,能不能动态的监控表的变化啊,是随时监控啊????
- 能否恢复被误删除(Delete清空)的Parodox表中的记录?快帮帮忙,要出人命了!!!
- 非常easy的问题!
var
Sr: TSearchRec;
PathName: string;
K: Integer;
begin
PathName := mDirName + '\*.*';
K := FindFirst(PathName, faAnyFile, Sr);
while K = 0 do begin
if (Sr.Attr and faDirectory > 0) and (Pos(Sr.Name, '..') = 0) then begin
FileSetAttr(Sr.Name, faDirectory);
// ~~~~~~~~~~加强删除只读、隐藏目录
ZsDelPath(mDirName + '\' + Sr.Name);
end else if Pos(Sr.Name, '..') = 0 then begin
FileSetAttr(Sr.Name, 0);
DeleteFile(PChar(mDirName + '\' + Sr.Name));
end;
K := FindNext(Sr);
end;
RmDir(mDirName);
end; { ZsDelPath }procedure TForm1.Button1Click(Sender: TObject);
begin
ZsDelPath('C:\Temp')
end;
procedure copyfile(Ahandle: THandle; FileName: String);
var
SHFileOpStruct: TSHFileOpStruct;
begin
with SHFileOpStruct do
begin
Wnd := AHandle;
wFunc:= FO_DELETE;
pFROM:= Pchar(FileName);
fFlags:= FOF_ALLOWUNDO;
end;
ShFileOperation(SHFileOpStruct);
end;上面主要是用到了ShFileOperation这个API函数,具体应该看的懂了把?呵呵