Logo

Programming-Idioms

History of Idiom 180 > diff from v6 to v7

Edit summary for version 7 by Bart:
[Pascal] Release handle

Version 6

2019-01-11, 17:07:11

Version 7

2019-01-13, 09:54:39

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
Imports
SysUtils, Classes
Code
  if FindFirst(IncludeTrailingPathDelimiter(d) + '*', 
               faAnyFile and (not faDirectory), SR) = 0 then
  repeat
    x.Add(SR.Name);
  until FindNext(SR) <> 0;
Code
  if FindFirst(IncludeTrailingPathDelimiter(d) + '*', 
               faAnyFile and (not faDirectory), SR) = 0 then
  repeat
    x.Add(SR.Name);
  until FindNext(SR) <> 0;
  FindClose(SR);
Comments bubble
A more classic implementation.
It will list only files, not the names of subdirectories inside p.
Comments bubble
A more classic implementation.
It will list only files, not the names of subdirectories inside p.