Click here to Skip to main content
15,902,879 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
What I want is, if user right-clicks a file and selects open with > my app, to at least get my app to get the file's directory. Hopefully, even open it in a textbox if it's a txt file or picture box if it's a picture file.
I am not asking about OpenFileDialog here, read clearly...

Thanks in advance,
John
Posted
Comments
[no name] 17-Dec-10 12:06pm    
"read clearly..." Then you will need to explain clearly.

"if user right-clicks a file and selects open with > my app" Do you mean from a File System Extension?
What is my app?
luisnike19 17-Dec-10 12:34pm    
Do you mean a Context menu to the Windows Explorer that executes your application?
Pete O'Hanlon 17-Dec-10 12:40pm    
We can only read clearly if you take the time to explain your requirements clearly. What you have laid out here is just so much gibberish, as it stands.

1 solution

If you are talking about console application, then in Main() method args[0] will hold full path to selected file.

If you are talking about WinForms application, you can use:
C#
string[] args = Environment.GetCommandLineArgs();

and again, args[0] should have full path to selected file.
 
Share this answer
 
Comments
Sandeep Mewara 17-Dec-10 13:55pm    
Comment from OP:
how do I use this to get the file's path? In C#.Net

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900