Logo

Programming-Idioms

History of Idiom 180 > diff from v2 to v3

Edit summary for version 3 by Bart:
New Pascal implementation by user [Bart]

Version 2

2019-01-11, 12:08:25

Version 3

2019-01-11, 12:26:13

Idiom #180 List files in directory

Create list x containing the contents of directory d.

x may contain files and subfolders.
No recursive subfolder listing.

Idiom #180 List files in directory

Create list x containing the contents of directory d.

x may contain files and subfolders.
No recursive subfolder listing.

Extra Keywords
folder ls dir listing
Extra Keywords
folder ls dir listing
Imports
SysUtils, Classes
Code
  if FindFirst(IncludeTrailingPathDelimiter(d) + '*', 
               faAnyFile and (not faDirectory), SR) = 0 then
  repeat
    x.Add(SR.Name);
  until FindNext(SR) <> 0;
Comments bubble
A more classic implementation.
It will list only files, not the names of subdirectories inside p.