Possible Duplicate:
C# Windows 'Open With >' Context menu behaviour
How do I do this? Like if I right click on a file and click open with, then my program how do I do stuff to that file :/.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I use the following code to pass the first argument (the one that contains the file name) to my gui application:
I test to see if there is an argument. If not and a user starts your program without one then you may get an exception in any code that tries to use it.
This is a snippet from my Form1 that deals with the incoming file:
You will see that I am checking the extension sent in – my app only works with one extension type – .bgl – so if the user tries to open some other file extension then I stop them. In this case I am dealing with a dropped file. This code will also allow a user to drag a file over my executable (or related icon) and the program will execute wit hthat file
You might also consider creating a file association between your file extension and your program if you have not already. This in conjunction with the above will allow the user to double click on your file and have your application open it.