What you need is a place in your MyProgram.cs class to store the command line arguments received in the constructor (Main).
Something like public string SelectedFile;
In the Main constructor, do this:
public static void Main(string[] args)
{ string SelectedFile;
if (args.Length > 0)
{
SelectedFile = Convert.ToString(args[0]);
MessageBox.Show(SelectedFile); // Just to confirm it.
}
MyProgram app = new MyProgram();
app.SelectedFile = SelectedFile;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(app);
}
No comments:
Post a Comment