Environment

This is easy, but 3 times over the last 2 years I've had to search for it, and it has taken me much longer to find it than is really appropriate.  I'm blogging it so I won't forget, and so others may be informed.

Environment.GetCommandLineArgs()

That is one of the sweetest functions in the .NET framework.  Not only does it return a string array with the arguments preloaded, but it intelligently splits the command string based on spaces and double-quoted characters.

app.exe test “This is a test” still testing

is returned as

test

“This is a test”

still

testing

Sweet! What could be simpler?

(Sometimes it the smallest things that make us happy.)

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)