I have a program that is going to run through the "Open with ..." menu and give the path file as input to the program. My code is as follows:
static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (args[0] != null)
{
Application.Run(new Form1(args[0]));
}
else
{
Application.Run(new Form1(""));
}
}
It will run correctly when given to the input program, but when I enter the program without input and normally, I get the following error:
System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'
Is there a way to solve this problem?