Hi!
I have an application made in c# which is like a notepad. I was wondering how can I set that when the user in windows right clicks a txt file and selects "open with..." and then my app it loads the file in it. Now it just opens the application without any text in it.
Any ideas?
Open with.. C# problem
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Aleksandar IlioskiRank #9,295 · 208 reputationPosted Mar 22, 2009, 5:13 PM EDT
When you try to open your program with (open with at some file), you pass two arguments to your program.
1-st one is path of your program, and 2-nd is path of that file...
So what you have to do is to make Open metod.. something like this:
public void Open (string path)
{
ritchTextBox.LoadFile(path);// and when you call that metod you will pass that second argument( path of that .txt file)
}
and in onLoad event call that metod something like this:
string path = Environment
.GetCommandLineArgs()[1] Open(path);blagoje ivanovic17 reputationPosted Mar 23, 2009, 2:49 AM EDT
One more thing: How can I make in load event that if the extension of the document is .doc then it opens it as a .doc file and if it's .rtf it opens it as a .rtf and so on?
Thanks in advance.
Aleksandar IlioskiRank #9,295 · 208 reputationPosted Mar 24, 2009, 4:35 PM EDT