open a known format file

  • Thread starter Thread starter Romain TAILLANDIER
  • Start date Start date
R

Romain TAILLANDIER

Hi group,

In my Windows File Explorer, when I double clic on a file that the format is
known by my system, it is open with the appropiated prog. ie : if i
double-clic on a .doc file, it is opened with Word, if it is a pdf file, it
is opened with accrobat reader....
if the file isn't a known format file the form "Open with..." popup and let
me choose the right prog to open it.

I have an application which allow user to select file, then i want to open
it exactlly like a double clic in Windows Explorer.
how to achieve that ??

(for the momment i switch on the extension of the file then use the right
prog, with new process() ...)

Thank your for help.
ROM
 
you do not need to map the extension to a program. Let Windows do that for
you.
Just run a new Process() with the name of the file.
For example, if it is an XLS file, then

System.Diagnostics.Process.Start("Foo.XLS");

I do not know what happens when the extension is not known - probably the
Process.Start() fails, and you will have to handle that situation in your
logic.

-Dino
 
Back
Top