blah blah blah is here! blah blah » Close

up1down
link

hello,

what i want is to work like this:

for example :

if i have .txt file but i don't want to open it in notepad i want to do "Open With" so i can see the .txt in my textbox1

last answered one year ago

1 answers

link

I think I'm right in saying that, when you use Open With, the OS calls the program in question with a command line argument equal to the full path of the file.

So, I'd try placing the following code in your Form1_Load eventhandler:

private void Form1_Load(object sender, EventArgs e)
{
string[] args = Environment.GetCommandLineArgs();
int len = args.Length;
if (len > 0)
{
textBox1.Text = System.IO.File.ReadAllText(args[len - 1]);
}
}

You'll also need to add your program to the Open With list for the file extension in question. To do that, I'd check out this link which also shows how to edit the registry to remove it.

king_888
153

thank you

Feedback