Spawning programs from a WinForms app

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
Back
Top