Visual C# 2005 Recipes
dows 2000, and Windows XP don't include path information, whereas Windows 98 and Windows ME
do. The GetCommandLineArgs method returns a string array containing the command-line arguments.
This array can be processed in the same way as the string array passed to the Main method, as dis-
cussed at the start of this section. Unlike the array passed to the Main method, the first element in
the array returned by the GetCommandLineArgs method is the filename of the application.
steps through each of the command-line arguments passed to it and displays them to the console.
The example then accesses the command line directly through the Environment class.
{
{
{
foreach (string s in args)
{
Console.WriteLine(Environment.CommandLine);
{
Console.WriteLine("\nMain method complete. Press Enter.");
Console.ReadLine();
four
'five
six'