Autor Beitrag
stigge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Do 12.06.08 13:07 
Ich möchte gerne einen Ordner nach Dateien mit bestimmten Endungen durchsuchen.
Was muss ich an diesem Code ändern, damit er GLEICHZEITIG nach mehreren Endungen sucht?
ausblenden volle Höhe 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:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
procedure GetFilesInDirectory(Directory: Stringconst Mask: Stringconst Mask2: Stringconst Mask3: String;
                              List: TStrings;
                              WithSubDirs, ClearList: Boolean);

procedure ScanDir(const Directory: String);
var
  SR: TSearchRec;
begin
  if FindFirst(Directory + Mask, faAnyFile and not faDirectory, SR) = 0 then try // Hier müsste der Code geändert werden
    repeat
      List.Add(Directory + SR.Name)
    until FindNext(SR) <> 0;
  finally
    FindClose(SR);
  end;

  if WithSubDirs then begin
    if FindFirst(Directory + '*.*', faAnyFile, SR) = 0 then try
      repeat
        if ((SR.attr and faDirectory) = faDirectory) and
           (SR.Name <> '.'and (SR.Name <> '..'then
          ScanDir(Directory + SR.Name + '\');
      until FindNext(SR) <> 0;
    finally
      FindClose(SR);
    end;
  end;
end;

begin
  List.BeginUpdate;
  try
    if ClearList then
      List.Clear;
    if Directory = '' then Exit;
    if Directory[Length(Directory)] <> '\' then
      Directory := Directory + '\';
    ScanDir(Directory);
  finally
    List.EndUpdate;
  end;
end;

Aufgerufen wird die Funktion so:
ausblenden Quelltext
1:
GetFilesInDirectory(directory, '*.rmt', '*.txt', '*.doc', filelist, false, true);					

Momentan sucht er ja nur Dateien mit der Endung Mask, was muss ich ändern das er auch Mask2 und Mask3 sucht?
Habs schon mit or versucht, hat aber nicht geklappt. Kann mir jemand helfen?


Moderiert von user profile iconNarses: Topic aus Windows API verschoben am Do 12.06.2008 um 13:54
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Do 12.06.08 13:36 
Schau mal in die Library dort wirst du fündig.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Do 12.06.08 14:03 
Ich würde dir zur Unit SearchTool von Heiko empfehlen. Die kann das auch so.
stigge Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 426

WinXP
Delphi 2007
BeitragVerfasst: Do 12.06.08 15:51 
Ah thx, für andere die auch einen solchen Code suchen:

www.delphi-library.d...en+suchen_21275.html