Scalabium Software

SMExport/SMImport suites
Knowledge for your independence'.
Home Delphi and C++Builder tips

#114: How can I load a file list by some wildcard?

After small delay with tip posting I want to continue this important task:-)

Today I'll post a small sample which show how you can receive a list of files from some specific directory by some custom wildcard. For example, to load in listbox the bmp-files from Windows directory.

procedure LoadFilesByMask(lst: TStrings; const SpecDir, WildCard: string);
  intFound: Integer;
  SearchRec: TSearchRec;
  intFound := FindFirst(SpecDir + WildCard, faAnyFile, SearchRec);
  while intFound = 0 do
    lst.Add(SpecDir + SearchRec.Name);
    intFound := FindNext(SearchRec);

For example, to load bmp-files from application folder:
LoadFilesByMask(lbFiles.Items, ExtractFilePath(Application.ExeName), '*.bmp')

Published: February 2, 2001

See also
SMImport suite
dBase Viewer
Clarion Viewer
SMMsg suite
SMExport suite
ExcelFile Viewer
Fast Document Viewer
Paradox Viewer
Viewer for MS Outlook Messages
Viewer for TNEF-files (winmail.dat)

Contact to webmaster


Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2018, Scalabium Software. All rights reserved.

SMExport advertising