How can I open a file with it's default program in a similar way to how I would use ShellExecute in VB6?
Thanks :)
Printable View
How can I open a file with it's default program in a similar way to how I would use ShellExecute in VB6?
Thanks :)
You`ll need to call a new process:
I think you will need to include "using System.Diagnostics;" in order to work.Code:Process showWordDoc = new Process();
showWordDoc.StartInfo.FileName = @"c:\myPath\myDoc.doc";
//showWordDoc.StartInfo.Arguments= ""; here you can put startup arguments
showWordDoc.StartInfo.UseShellExecute = true;
showWordDoc.Start();
showWordDoc.WaitForExit();
showWordDoc.Close();
BTW: there are a lot more otions than the ones I posted, just look into them, all easy to understand.
HTH, Stephan
Sgt-Peppa, that is too much crap. He doesn't need all that just to execute a file
Process.Start("My.html")
done
WOW :eek: was not aware of that, it works :confused: !Quote:
Sgt-Peppa, that is too much crap. He doesn't need all that just to execute a file
I never opend up a file,.. just called a lot of processes and needed to pass arguments.
So i thought thats the way to do it, you proved me wrong, and I learned, thanks
Stephan
I get "The type or namespace name 'Process' could not be found (are you missing a using directive or an assembly reference?)"Quote:
Originally posted by kasracer
Sgt-Peppa, that is too much crap. He doesn't need all that just to execute a file
Process.Start("My.html")
done
Do I need a "using..."?
Quote:
Originally posted by Sgt-Peppa
I think you will need to include "using System.Diagnostics;" in order to work.
HTH, Stephan
Ahh I thought that was just for your example. Thank you both :)
lol no problem.Quote:
Originally posted by Sgt-Peppa
WOW :eek: was not aware of that, it works :confused: !
I never opend up a file,.. just called a lot of processes and needed to pass arguments.
So i thought thats the way to do it, you proved me wrong, and I learned, thanks
Stephan
I think the full path, so you don't have to include System.Diagnostics is like
System.Diagnostics.Process.Start("OMG.vb")
was that sarcasm or truth?
uh?Quote:
Originally posted by Danny J
was that sarcasm or truth?