Amerikon
January 17th, 2008, 03:21 PM
I'm writing a simple C# console app (in Windows Vista) that gets a file and has to open it in the default editor for that file type. I'm using some code like this:
proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = (path + fileName);
if (proc.Start()) {
//Do Stuff
} else {
//No Process was returned so I can't do anything!
return failure;
}
I need the process object so (at a minimum) I can know when the application has been closed. It works fine for any installed application (including MS Office), however if I'm given a jpg or a wmv file that opens up in one of MS's embedded applictions (Photo Gallery and Media Player respectively) the proc.Start() call returns false and the Process object is unassigned even though calling proc.Start() does actually call up the file in it's default application. I don't normally do a lot of Windows specific programming so I'm wondering if there's something simple that I'm missing.
Thanks.
proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = (path + fileName);
if (proc.Start()) {
//Do Stuff
} else {
//No Process was returned so I can't do anything!
return failure;
}
I need the process object so (at a minimum) I can know when the application has been closed. It works fine for any installed application (including MS Office), however if I'm given a jpg or a wmv file that opens up in one of MS's embedded applictions (Photo Gallery and Media Player respectively) the proc.Start() call returns false and the Process object is unassigned even though calling proc.Start() does actually call up the file in it's default application. I don't normally do a lot of Windows specific programming so I'm wondering if there's something simple that I'm missing.
Thanks.