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). 


'Using the OS pattern matching
For Each file In IO.Directory.GetFiles("\temp", "*.txt")
  Console.WriteLine(file)
Next
 
'Using VB's pattern matching and LINQ
For Each file In (From name In IO.Directory.GetFiles("\temp") Where name Like "*.txt")
  Console.WriteLine(file)
Next
 
'Using VB's pattern matching and dot-notation
For Each file In IO.Directory.GetFiles("\temp").Where(Function(f) f Like "*.txt")
  Console.WriteLine(file)
Next