Declaration
procedure GetAllFiles(Path: String; Dest: TStrings; GetFiles: boolean = True; GetDirs: boolean = False; AllowHidden: Boolean = False); overload;
procedure GetAllFiles(Path: String; Dest: TStrings; GetFiles: boolean; GetDirs: boolean; AllowHidden: Boolean; IncludeSubFolders: Boolean; Limit: Integer = 2000; IncludePath: Boolean = True); overload;
Description
Add names of all files in the specified path to a strings object. Use the overload if you want to include files in sub-folders too (up to the specified limit).
Path must include a wildcard, e.g. '.\*.jpeg' or 'C:\Images\*.*'
Note:
◼If Path does not include *.*, it will be appended automatically
◼Returned names INCLUDE the path
Also see:
GetFirstFile
| Demos\PDF\PdfPrinter\PdfPrinter.dpr |
// Delete GIF files in C:\Temp\
ss := TStringList.Create;
GetAllFiles( 'C:\Images\*.gif', ss );
for i := 0 to ss.Count - 1 do
DeleteFile( ss[i] );
ss.Free;
// Show all files in C:\Images
ss := TStringList.Create;
GetAllFiles( 'C:\Images', ss );
ShowMessage( ss.Text );
ss.Free;