Let windows decide how to open / run the file?

I am saving files (images, Excel documents, Word documents, exe files, bat files, etc.). I need to execute a file from within my program, and the question is, is there a way to allow Windows to handle starting / executing the file? For example, when you double click on a file in Explorer?

+3


source to share


2 answers


Take a look at the Process.Start method :

System.Diagnostics.Process.Start(myFileName)

      

Note. This will work with any registered file extension like



System.Diagnostics.Process.Start(@"c:\Image.bmp")

      

will open the image with the registered program.

+13


source


Start a new process with the saved file path name as a parameter:



System.Diagnostics.Process.Start(pathToYourFile);

      

+3


source







All Articles