How do I expand wildcard arguments in the Main (Stirng [] args) ?

  • Thread starter Thread starter rogdh
  • Start date Start date
R

rogdh

My main looks like
static void Main ( String [] args)

When launch the Windows application with a wildcard parameters, they
are not expanded.
What I get is what I entered.

How do I expand wildcard input?

tia.

roger
 
rogdh,

I think this might help you:

(using System.IO;)
DirectoryInfo dir = new DirectoryInfo(@"c:\program files");
FileInfo[] files = dir.GetFiles("*.*);
foreach(FileInfo file in files) {
// process files here
}

Reply if it's not what you need,
Scott

rogdh said:
Yes, file names.



What are you trying to pass as an argument? A filename?

Brian Patterson
rogdh said:
My main looks like
static void Main ( String [] args)

When launch the Windows application with a wildcard parameters, they
are not expanded.
What I get is what I entered.

How do I expand wildcard input?

tia.

roger
 
I was thinking right along the lines of Scotts code but a bit more like so:

DirectoryInfo dir = new DirectoryInfo(Environment.CurrentDirectory);
FileInfo[] files = dir.GetFiles(args[1]);
foreach(FileInfo file in files)
{
// process files here
}

That way it searches your wildcards in the directory you launched your
application from.

Brian Patterson


Scott said:
rogdh,

I think this might help you:

(using System.IO;)
DirectoryInfo dir = new DirectoryInfo(@"c:\program files");
FileInfo[] files = dir.GetFiles("*.*);
foreach(FileInfo file in files) {
// process files here
}

Reply if it's not what you need,
Scott

rogdh said:
Yes, file names.



What are you trying to pass as an argument? A filename?

Brian Patterson
My main looks like
static void Main ( String [] args)

When launch the Windows application with a wildcard parameters, they
are not expanded.
What I get is what I entered.

How do I expand wildcard input?

tia.

roger
 
No that will not be acceptable.
At work my system admin is putting all relevant file in 1 folder...
over 6500 items.
That type of "work around" would take forever.
I really need correct wildcard expansion.

Thank you anyway.,
roger

rogdh,

I think this might help you:

(using System.IO;)
DirectoryInfo dir = new DirectoryInfo(@"c:\program files");
FileInfo[] files = dir.GetFiles("*.*);
foreach(FileInfo file in files) {
// process files here
}

Reply if it's not what you need,
Scott

rogdh said:
Yes, file names.



What are you trying to pass as an argument? A filename?

Brian Patterson
My main looks like
static void Main ( String [] args)

When launch the Windows application with a wildcard parameters, they
are not expanded.
What I get is what I entered.

How do I expand wildcard input?

tia.

roger
 
"Work Around"?? I'm afraid this is your only option my friend - take it or
leave it. The code you are looking at IS "Wildcard Expansion"

rogdh said:
No that will not be acceptable.
At work my system admin is putting all relevant file in 1 folder...
over 6500 items.
That type of "work around" would take forever.
I really need correct wildcard expansion.

Thank you anyway.,
roger

rogdh,

I think this might help you:

(using System.IO;)
DirectoryInfo dir = new DirectoryInfo(@"c:\program files");
FileInfo[] files = dir.GetFiles("*.*);
foreach(FileInfo file in files) {
// process files here
}

Reply if it's not what you need,
Scott

rogdh said:
Yes, file names.



On Mon, 28 Jul 2003 21:46:53 -0500, "Brian Patterson"

What are you trying to pass as an argument? A filename?

Brian Patterson
My main looks like
static void Main ( String [] args)

When launch the Windows application with a wildcard parameters, they
are not expanded.
What I get is what I entered.

How do I expand wildcard input?

tia.

roger
 
Brian, get a clue.
What I was getting was a filter. NOT expansion.


"Work Around"?? I'm afraid this is your only option my friend - take it or
leave it. The code you are looking at IS "Wildcard Expansion"

rogdh said:
No that will not be acceptable.
At work my system admin is putting all relevant file in 1 folder...
over 6500 items.
That type of "work around" would take forever.
I really need correct wildcard expansion.

Thank you anyway.,
roger

rogdh,

I think this might help you:

(using System.IO;)
DirectoryInfo dir = new DirectoryInfo(@"c:\program files");
FileInfo[] files = dir.GetFiles("*.*);
foreach(FileInfo file in files) {
// process files here
}

Reply if it's not what you need,
Scott

Yes, file names.



On Mon, 28 Jul 2003 21:46:53 -0500, "Brian Patterson"

What are you trying to pass as an argument? A filename?

Brian Patterson
My main looks like
static void Main ( String [] args)

When launch the Windows application with a wildcard parameters,
they
are not expanded.
What I get is what I entered.

How do I expand wildcard input?

tia.

roger
 
Don't be such as dumb ass. Why don't you tell all of us what the difference
is? Better yet, give us your interpretation on how you think windows
expands at the command prompt? Possibly by getting a list of the files and
showing the first match according to the typed letters? Or is there
supposed to be some magical API that does everything for you? Get some
balls and sit down and write the code instead of whining.


rogdh said:
Brian, get a clue.
What I was getting was a filter. NOT expansion.


"Work Around"?? I'm afraid this is your only option my friend - take it or
leave it. The code you are looking at IS "Wildcard Expansion"

rogdh said:
No that will not be acceptable.
At work my system admin is putting all relevant file in 1 folder...
over 6500 items.
That type of "work around" would take forever.
I really need correct wildcard expansion.

Thank you anyway.,
roger

On Tue, 29 Jul 2003 09:05:27 +0200, "Scott"

rogdh,

I think this might help you:

(using System.IO;)
DirectoryInfo dir = new DirectoryInfo(@"c:\program files");
FileInfo[] files = dir.GetFiles("*.*);
foreach(FileInfo file in files) {
// process files here
}

Reply if it's not what you need,
Scott

Yes, file names.



On Mon, 28 Jul 2003 21:46:53 -0500, "Brian Patterson"

What are you trying to pass as an argument? A filename?

Brian Patterson
My main looks like
static void Main ( String [] args)

When launch the Windows application with a wildcard parameters,
they
are not expanded.
What I get is what I entered.

How do I expand wildcard input?

tia.

roger
 
Hey Brian... I KNOW you!!!
I saw you yesterday on the freeway. You were the guy yelling at people
at 60 MPH from the safety of your car... right?

I bet you're a really little guy.

Don't be such as dumb ass. Why don't you tell all of us what the difference
is? Better yet, give us your interpretation on how you think windows
expands at the command prompt? Possibly by getting a list of the files and
showing the first match according to the typed letters? Or is there
supposed to be some magical API that does everything for you? Get some
balls and sit down and write the code instead of whining.


rogdh said:
Brian, get a clue.
What I was getting was a filter. NOT expansion.


"Work Around"?? I'm afraid this is your only option my friend - take it or
leave it. The code you are looking at IS "Wildcard Expansion"

No that will not be acceptable.
At work my system admin is putting all relevant file in 1 folder...
over 6500 items.
That type of "work around" would take forever.
I really need correct wildcard expansion.

Thank you anyway.,
roger

On Tue, 29 Jul 2003 09:05:27 +0200, "Scott"

rogdh,

I think this might help you:

(using System.IO;)
DirectoryInfo dir = new DirectoryInfo(@"c:\program files");
FileInfo[] files = dir.GetFiles("*.*);
foreach(FileInfo file in files) {
// process files here
}

Reply if it's not what you need,
Scott

Yes, file names.



On Mon, 28 Jul 2003 21:46:53 -0500, "Brian Patterson"

What are you trying to pass as an argument? A filename?

Brian Patterson
My main looks like
static void Main ( String [] args)

When launch the Windows application with a wildcard parameters,
they
are not expanded.
What I get is what I entered.

How do I expand wildcard input?

tia.

roger
 
Brian, I seemed to sense aggivation, hostility (something) in your
response of 7/30/2003 1:32pm.
If this was NOT the case I apologize.



Is it not true that in MS C environment linking with setargv.obj
provides true wildcard expansion without need to filter.



Reference below...

Expanding Wildcard Arguments
Microsoft Specific ®

When running a C program, you can use either of the two wildcards -
the
question mark (?) and the asterisk (*) - to specify filename and path
arguments on the command line.

Command-line arguments are handled by a routine called _setargv (or
_wsetargv in the wide-character environment), which by default does
not
expand wildcards into separate strings in the argv string array. You
can
replace the normal _setargv routine with a more powerful version of
_setargv that does handle wildcards by linking with the SETARGV.OBJ
file. If your program uses a wmain function, link with WSETARGV.OBJ.

To link with SETARGV.OBJ or WSETARGV.OBJ, use the /link option. For
example:

cl typeit.c /link setargv.obj

The wildcards are expanded in the same manner as operating system
commands. (See your operating system user's guide if you are
unfamiliar
with wildcards.) Enclosing an argument in double quotation marks (" ")
suppresses the wildcard expansion. Within quoted arguments, you can
represent quotation marks literally by preceding the
double-quotation-mark character with a backslash (\). If no matches
are
found for the wildcard argument, the argument is passed literally.

END Microsoft Specific
 
Back
Top