You're here: Snippet Directory » Delphi (11)
Language:

Dateien mit Maske aus Verzeichnis lesen

Language: Deutsch
Programming Language: Delphi
Published by: pumi
Last Update: 5/16/2006
Views: 1401


Description

Dateien mit Maske aus Verzeichnis lesen
function ReadDir(Path, Mask: string; ShowPath: boolean): TStringlist;

Code

1 function ReadDir(Path, Mask: string; ShowPath: boolean): TStringlist; 2 3 var SRec: TSearchRec; 4 5 begin 6 7 Path := IncludeTrailingBackslash(Path); 8 9 result := TStringList.Create; 10 11 try 12 13 if FindFirst(Path + Mask, not faDirectory, SRec) <> 0 then exit; 14 15 repeat 16 17 case ShowPath of 18 19 True: result.Add(Path + SRec.Name); 20 21 False: result.Add(SRec.Name); 22 23 end; 24 25 until FindNext(SRec) <> 0; 26 27 finally 28 29 FindClose(SRec); 30 31 end; 32 33 end; 34 35 36 37 //Aufruf zB: 38 39 procedure TForm1.btnFillListboxClick(Sender: TObject); 40 41 begin 42 43 listbox1.items := ReadDir('c:\test', '*.*', true); 44 45 end;

No comments avaiable

Add a comment

Name *  

Email (won't be displayed) *    

Website  

Comment *  

Sicherheitscode Security Code *    

RSS