Autor Beitrag
barana
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Di 10.04.07 13:32 
Hallo Leute,

gibt es eine Möglichkeit mit Delphi einen ganzen Ordner sammt Inhalt zu löschen?

Danke im Voraus
FiceGoesDelphi
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Di 10.04.07 13:47 
Kann ich dir als Delphi Newbie (schöne grüße an Stefan :lol: ) nicht 100% beantworten!
Also man kann mit delphi ALLES machen ;)
Nur ob es sich lohnt usw ist die andere frage!
Du kannst ja z.B. eine einfache Batch datei schreiben. 5 min Google Arbeit und du hast deine Batchdatei die Ordner samt Inhalt löscht!

_________________
<(^^<) <(^^)> (>^^)>
===================
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: Di 10.04.07 13:51 
Hallo!

Oder du verwendest die folgende Funktion:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
uses ShellAPI;

function DeleteFile(const AFile: string): boolean;
var
 sh: SHFileOpStruct;
begin
 ZeroMemory(@sh, sizeof(sh));
 with sh do
   begin
   Wnd := Application.Handle;
   wFunc := fo_Delete;
   pFrom := PChar(AFile +#0);
   fFlags := fof_Silent or fof_NoConfirmation;
   end;
 result := SHFileOperation(sh) = 0;
end;


Aufrufen kannst sie so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
begin
 if DeleteFile('c:\Programme\Borland\*.*') then   //alles löschen
   ...
 if DeleteFile('c:\Programme\') then       //um ein Verzeichnis zu löschen
   ...
 if DeleteFile('c:\Programme\test.txt') then //Datei löschen
   ...
end;


Alles natürlich in Delphi :mrgreen:

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
barana Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Mi 11.04.07 19:43 
danke...