Awhile back in a post that I shall dub Part 1, I talked about how to create the context menu in explorer that would point to a program. Today it's time to show how little code it requires to send a path to a winform app.
Open up your Program.cs (in 2.0) or whatever class that contains your Main method. Make your method designation the same as below:
static void Main(string[] args)
This will allow arguments to be passed into the method from an outside source. Inside your method you'll want:
Form1 f = new Form1();
if (args.Length > 0)
{
f.Path = args[0];
}
Application.Run(f);
This will set the Path variable on your winform to the argument passed in. Do what you will with your public accesor. Mine looks like:
public string Path
{
get { return this.fbd.SelectedPath; }
set
{
this.fbd.SelectedPath = value;
this.txtDirectory.Text = value;
}
}
Cherio then.