Spawning programs from a WinForms app

G

Guest

Hi.
I have a WinForms app, .NET and C#. I have a textbox with a filename (e.g.
X.pdf, Y.xls or Z.txt). When the user double clicks on the textbox, I want
to execute the program associated with the particular extension (i.e. Adobe
Acrobat Reader, Excel or Notepad). Probably, this is solved somewhere in the
..NET Class Library, but where?

Regards,
Gudni
 
G

Guest

Hi again.
It seems that I have found a solution, if not the best or standard one. It
goes like this:

using System;
using System.Diagnostics;
using System.ComponentModel;
....
string fileName = listBoxFiles.SelectedItem.ToString();
Process myProc = new Process();
myProc.StartInfo.FileName = fileName;
myProc.Start();
....

Would this be the way to do this?

Regards,
Gudni
 
G

Guest

Gudni said:
Hi.
I have a WinForms app, .NET and C#. I have a textbox with a filename (e.g.
X.pdf, Y.xls or Z.txt). When the user double clicks on the textbox, I want
to execute the program associated with the particular extension (i.e. Adobe
Acrobat Reader, Excel or Notepad). Probably, this is solved somewhere in the
.NET Class Library, but where?

Regards,
Gudni

http://www.google.se/search?q=c#+start+program
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top