Zavael Zavael - 4 months ago 24
C# Question

Open file with associated application

i want to ask for help with opening a file from c# app with associated app.
I tried this:

ProcessStartInfo pi = new ProcessStartInfo(file);
pi.Arguments = Path.GetFileName(file);
pi.UseShellExecute = true;
pi.WorkingDirectory = Path.GetDirectoryName(file);
pi.FileName = file;
pi.Verb = "OPEN";

or this:


where string
in both examples represents full path to the file trying to open. Now, everything is working well, except the (jpg) images with ACDSee app. Irfanview associations works well, MS office documents too. After trying to open the jpg image associated with acdsee it just runs the acdsee in the notification area and does not open the file.

I discovered, that in the registry CLASSES_ROOT for *.jpg images, there is an ACDSee.JPG value as associated app, and under this key there is in the shell->Open->Command a path:

"C:\Program Files\ACD Systems\ACDSee\ACDSee.exe" /dde

and I thing that this weird
is the reason, why i cannot open the file. I realized that in the same reg key shell->Open there is some
key entry with value

For Irfan view or other checked app there is not a ddeexec, just the normal command like

"C:\Program Files (x86)\IrfanView\i_view32.exe" "%1"

that can be run from command line after swaping the %1 for file name, but I could not run the command from acdsee entry in the command line :(

So my question is, how can I set up the
object to ensure that it will run all the files as it would be in the explorer by doubleclick, the standards and this
ones? Is there something other like
that I shoul be aware of?
thanks and sorry for my EN


Just write

System.Diagnostics.Process.Start(@"file path");



And shell will run associated program reading it from the registry, like usual double click does.