function TFDataExport.DelDiskAFiles: Boolean; Var FileList:TFileListBox; FileCount:integer; begin try FileList:=TFileListBox.Create(nil); FileList.Width:=0; FileList.Height:=0; FileList.Parent:=FDataExport.Panel1.Parent; FileList.Hide; FileList.Mask:='A:\*.*'; For FileCount:=0 to FileList.Items.Count-1 do if DeleteFileA(PChar(FileList.Items.Strings[FileCount])) then //???? showmessage('ok') else ShowMessage('error'); Result:=True; except FileList.Free; Result:=False; end;end;
filelistbox中的文件名没有路径,自己加上
if DeleteFileA(PChar(FileList.Directory+FileList.Items.Strings[FileCount])) then
应该再加个杠, if DeleteFileA(PChar(FileList.Directory+'\'+FileList.Items.Strings[FileCount])) then
Var
FileList:TFileListBox;
FileCount:integer;
begin
try
FileList:=TFileListBox.Create(nil);
FileList.Width:=0;
FileList.Height:=0;
FileList.Parent:=FDataExport.Panel1.Parent;
FileList.Hide;
FileList.Mask:='A:\*.*'; For FileCount:=0 to FileList.Items.Count-1 do
if DeleteFileA(PChar(FileList.Items.Strings[FileCount])) then //????
showmessage('ok')
else
ShowMessage('error');
Result:=True;
except
FileList.Free;
Result:=False;
end;end;
if DeleteFileA(PChar(FileList.Directory+'\'+FileList.Items.Strings[FileCount])) then