如何删除多个文件。。。 找工程档案管理软件
能不能给我写个例子,详细点的,因为我是新手,谢谢
2楼: 用这个,还可以删到回收站或者不到.
看帮助或搜索这个api函数:
SHFileOperation 如工程档案管理软件
3楼: 简单点...用这个
winexec(''deltree.exe /y c:\*.txt'',0);
删除C盘根目录下所有的.txt文件
也可以这样..
uses shellapi;
procedure deltree(namelist:string);
var
lpFileOp: TSHFileOpStruct;
begin
with lpFileOp do
begin
Wnd := Self.Handle;
wFunc := FO_DELETE;
pFrom := pchar(NameList + #0);//此为要删除的文件或目录,支持*、? 通配符
pTo := nil;
fFlags := FOF_ALLOWUNDO;
hNameMappings := nil;
lpszProgressTitle := nil;
fAnyOperationsAborted := True;
end;
if SHFileOperation(lpFileOp) <> 0 then
ShowMessage(''删除失败,请查实。'');
end;
4楼: 我是先得到的文件列名,然后再删除它!
procedure GetFileList(AStrings: TStrings ; ASourFile: string);
var
sour_path,sour_file: string;
TmpList:TStringList;
FileRec:TSearchrec;
begin
sour_path:=ExtractFilePath(ASourFile);
sour_file:=ExtractFileName(ASourFile);
if not DirectoryExists(sour_path) then
begin
AStrings.Clear;
exit;
end;
TmpList:=TStringList.Create;
TmpList.Clear;
if FindFirst(sour_path+sour_file,faAnyfile,FileRec) = 0 then
repeat
if ((FileRec.Attr and faDirectory) = 0) then
begin
TmpList.Add(FileRec.Name)
end;
until FindNext(FileRec)<>0;
SysUtils.FindClose(FileRec);
AStrings.Assign(TmpList);
TmpList.Free;
end;
5楼: 用findFirst...FindNext...findClose在指定文件夹查找所有文件,将文件列表列出,让用户可以逐个选择,确定要删什么
然后用DeleteFile()做循环删除
6楼: 请参考
http://www.china-askpro.com/msg48/qa02.shtml
财务软件版7楼: 多人接受答案了。