Results 1 to 3 of 3

Thread: Program Parameters *SOLVED*

  1. #1

    Thread Starter
    Addicted Member DJ_Catboy's Avatar
    Join Date
    Jan 2003
    Location
    Suffolk, UK
    Posts
    159

    Program Parameters *SOLVED*

    Code:
    [STAThread]
    static void Main(string[] args) 
    {
    int x = args.GetUpperBound(0);
    if (x == -1) {
    	MessageBox.Show("No Parameters!");
    } else {
    	Application.Run(new frmMain(args[0]));
    }
    }
    I am trying to use command line parameters in my application but it does not work. Is there anything wrong with the code above?

    Hope somebody can help!

    DJ
    Last edited by DJ_Catboy; Sep 3rd, 2003 at 11:44 AM.

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Code:
    static void Main(string[] args) {
        if (args.GetLength(0) > 0) {
            Console.WriteLine(String.Format("We have args! - {0}", args[0]));
        }
        else {
            Console.WriteLine("We do not have args!");
        }
    }

  3. #3

    Thread Starter
    Addicted Member DJ_Catboy's Avatar
    Join Date
    Jan 2003
    Location
    Suffolk, UK
    Posts
    159
    Many thanks! Works like a charm!

    DJ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width