this slowpoke moves

Delete Specifies files in folder

uses FileCtrl

procedure DeleteFilesInDirectory(const Path:String);
var I, R : Integer; 
	SR : TSearchRec; 
    List : TStringList;
begin
   List := TStringList.Create;
   R := FindFirst(Path + '\*.*',  // HIER KANN ANGEGEBEN WERDEN WELCHE DATEIEN GELÖSCHT WERDEN SOLLEN
                  faAnyFile,SR);
   try
   while R = 0 do begin
      if (SR.Attr and faDirectory <> faDirectory) then
      List.Add(Path + '/' + SR.Name);
      R := FindNext(SR);
   end;
   FindClose(SR);
   for I : =0 to List.Count-1 do 
   DeleteFile(List[I]);
   finally
   List.Free;
 end;
end;
Ordner laden :
procedure TForm1.Button1Click(Sender: TObject);
var
  Directory: string;
begin
  if SelectDirectory('Select directory', '', Directory) then
  ShowMessage('You''ve selected directory ' + Directory);
  Edit1.Text := Directory;
end;
Dateien löschen :
procedure TForm1.Button2Click(Sender: TObject);
begin
  DeleteFilesInDirectory(Edit1.Text);
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate