I am saving files (images, Excel doc, Word doc, exe files, bat files and so on). I need to execute the file from inside my program and the question is if there is a way to let Windows handle how to run/execute the file? Like when you double click on a file in Explorer?
Asked
Active
Viewed 2,907 times
2 Answers
13
Take a look at the Process.Start method:
System.Diagnostics.Process.Start(myFileName)
Note: this will work with any registered file-extension, for example
System.Diagnostics.Process.Start(@"c:\Image.bmp")
will open the image with the registered program.
![](../../users/profiles/76051.webp)
Carsten
- 49,407
- 9
- 85
- 111
3
Start new process with the saved file path name as a parameter:
System.Diagnostics.Process.Start(pathToYourFile);
![](../../users/profiles/325322.webp)
Karel Frajták
- 4,409
- 20
- 33