Jump to content


Getting at the command line?!

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Kallisti

Kallisti

    Enthusiast

  • Members
  • PipPipPip
  • 243 posts
Right, the Command object doesn't work (it's there, just throws an exception if you try and use it in the compact framework), and Environment doesn't have any command line variables in it that I can find.

So how do I get at the command line arguments that I've included in the shortcut to my app?


#2
Peter Foot

Peter Foot

    Regular

  • Members
  • PipPip
  • 83 posts
  • Location:Birmingham, UK
  • Interests:.NETCF, Photography, Walkies
  • Devices:HTC S620
Use an overload of your sub Main which accepts an array of strings - which will receive your application arguments e.g.

public class Form1 : System.Windows.Forms.Form
{

static void Main(string[] args)
{
   Application.Run(new Form1(args));
}

public Form1(string[] args)
{
   InitializeComponent();

  //setup your form stuff here and populate controls, fields etc using arguments as required
}

//other methods properties etc
}

Peter Foot
Windows Embedded MVP
www.inthehand.com | www.peterfoot.net




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users