views:

131

answers:

1

I am doing a command line app that needs to read some files and do some processing.

There can be many file arguments on the command line, and each of these can be in one of the following formats:

  • Relative path, with or without wildcards.
  • Complete path, with or without wildcards.

Network shares should be supported.

What is the easiest way to get a collection of all the files matching the command line arguments ?

Examples of command lines that should be supported:

tool.exe myfile.dat
tool.exe myfile.*
tool.exe ..\..\*.*
tool.exe C:\Temp\test.*
tool.exe \\server\share\*.dat

Is there nothing built-in in the framework to do this ?

+3  A: 

This question has a couple of good code samples and some discussion. Here is another article that explains it and the code is a little simpler.

mdm
This seems to be the way to do it. I had hoped there was a built-in way to achieve this (would be good for consistency between different console programs).
driis