Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a file not using default program

Tags:

c#

file-type

How in c# can I make a file open with a specified program ie: not the default program for that file type

like image 334
Froodle Avatar asked Sep 06 '25 03:09

Froodle


1 Answers

If you can build a command-line to run the program (including passing the input file as a command-line parameter) than build the command line ans use Process.Start.

Of course this assumes

  1. you know the path to the program's executable
  2. you know how to pass the filename as a command-line parameter.

How 2. works depends on the program. It could be as simple as

Process.Start("MyProgram.exe","MyFile.dat")

But other programs may require a command-line switch or other information.

like image 96
D Stanley Avatar answered Sep 07 '25 21:09

D Stanley