Autor Beitrag
Radioactive
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179

Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
BeitragVerfasst: So 27.02.05 16:33 
Ich verwende diese von mir geschriebene Procedure zum Löschen aller Dateien und Unterordner:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
procedure DeleteDirContent(Dir: String);
var F: TSearchRec;
begin
  if Dir[Length(Dir)] = '\' then Dir := copy(Dir,1,Length(Dir)-1);
  if DirectoryExists(Dir) then
  begin
    // alle Dateien und Unterordner aus dem Ordner löschen
    if FindFirst(Dir+'\*.*',faDirectory,F) = 0 then
    begin
      try
        repeat
          if (F.Name <> '.') and (F.Name <> '..') then
          begin
            if (F.Attr and faDirectory) = faDirectory then
            begin
              DeleteDirContent(Dir+'\'+F.Name);
              RemoveDir(Dir+'\'+F.Name);
            end else      
              DeleteFile(PChar(Dir+'\'+F.Name));
          end;
        until FindNext(F) <> 0;
      finally
        FindClose(F);  // <--------  hier kommt der Error
      end;
    end; 
  end;
end;

Beim komplimieren kommt jedoch ein Fehler: Inkompatible Typen: 'Cardinal' und 'TSearchRec'. Ich vermute, er will die API-Funktion statt der gleichnamigen Delphi-Funktion verwenden. Wie treibe ich ihm das aus (die Unit Windows kann ich nicht entfernen)?

_________________
Radioactive
"Wer scrollt, verliert!" Matthias Stein, Informatiklehrer am GG
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: So 27.02.05 16:46 
Hast du irgendwelche anderen Variablen, die f heißen?

AXMD
Radioactive Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179

Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
BeitragVerfasst: So 27.02.05 16:52 
Nein, die procedure ist in einer eigenen Unit und da gibt es nur einmal F. Wie gesagt, ich vermute, er will die Windows-API-Funktion benutzen.

_________________
Radioactive
"Wer scrollt, verliert!" Matthias Stein, Informatiklehrer am GG
Luca
Hält's aus hier
Beiträge: 13



BeitragVerfasst: So 27.02.05 17:14 
Probier mal einfach die Zeile

ausblenden Delphi-Quelltext
1:
FindClose(F);  // <--------  hier kommt der Error					


durch zu ersetzen

ausblenden Delphi-Quelltext
1:
SysUtils.findClose(F);					
Radioactive Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179

Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
BeitragVerfasst: So 27.02.05 17:19 
JAAAAAAHHH!!! Es geht! *freu* Danke! :)

_________________
Radioactive
"Wer scrollt, verliert!" Matthias Stein, Informatiklehrer am GG