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?
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: String; const Mask: String; const Mask2: String; const 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 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:
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
Narses: Topic aus Windows API verschoben am Do 12.06.2008 um 13:54