Reputation: 1073
I wish to be able to open my C# forms application (image viewer) with, for example, a jpg or gif. What would I have to do to allow the application to read the file-path of that file so that it can process it accordingly?
The application is working fine; all I need to do now is make sure that it can display a picture immediately if it is set to the default for images like jpg, gif etc.
Upvotes: 1
Views: 65
Reputation: 7415
You can use Environment.GetCommandLineArgs ();
As the documentation describe:
The first element in the array contains the file name of the executing program. If the file name is not available, the first element is equal to String.Empty. The remaining elements contain any additional tokens entered on the command line.
So, in your case, the image file path that 'starts'your application should be the second element of the array returned by Environment.GetCommandLineArgs ().
Upvotes: 1