Task

Walk a given directory and print the names of files matching a given pattern.

(How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?)


Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree.

Note: Please be careful when running any code presented here.



Related task

   Walk Directory Tree   (read entire directory tree). 


 
program Walk_a_directory;
 
{$APPTYPE CONSOLE}
{$R *.res}
 
uses
  System.IOUtils;
 
var
  Files: TArray<string>;
  FileName, Directory: string;
 
begin
  Directory := TDirectory.GetCurrentDirectory;  // dir = '.', work to
  Files := TDirectory.GetFiles(Directory, '*.*');
 
  for FileName in Files do
  begin
    Writeln(FileName);
  end;
 
  Readln;
end.
 
 