3

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
  • 1
    Doesn't the shell expand wildcards before passing arguments to the process? Commented Jan 9, 2010 at 12:27
  • Just to clarify - you want a "generic" argument? And I assume the user will be a "super" or "power" user? Commented Jan 9, 2010 at 12:38
  • @dragthor, I am asking how to expand the arguments so I always get the collection of files the user expects. Commented Jan 9, 2010 at 13:18

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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).
Second link appears to be broken.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.