You can find an example at http://www.delphibasics.co.uk/RTL.asp?Name=FindFirst.
Example code : Find all directories above and including the current onevar searchResult : TSearchRec;begin // Try to find directories above the current directory SetCurrentDir('..'); if FindFirst('*', faDirectory, searchResult) = 0 then begin repeat // Only show directories if (searchResult.attr and faDirectory) = faDirectory then ShowMessage('Directory = '+searchResult.Name); until FindNext(searchResult) <> 0; // Must free up resources used by these successful finds FindClose(searchResult); end;end;
if FindFirst('*', faAnyFile, searchResult) = 0 theninstead of if FindFirst('*', faDirectory, searchResult) = 0 then