G
Guest
Hi,
I have an application that is launching a process (see the code below) to
perfom some operation on a file. On Windows 2000, if my application first
uses the OpenFileDialog to open a file on the desktop, Process.Start failes
with the following exception:
System.ComponentModel.Win32Exception: The system cannot find the file
specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo
startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
The code is roughly as follows:
// here we ask the user to open a file
OpenFileDialog openFileBox = new OpenFileDialog();
openFileBox.Filter = mAddFileFilter.ToString();
openFileBox.FilterIndex = 1;
if(openFileBox.ShowDialog() == DialogResult.OK) {
inputFilePath = openFileBox.FileNames;
}
// later we launch a process to perform an operation on the file
outputFilePath = System.IO.Path.GetTempFileName();
string arguments = "\"" + inputFilePath + "\" \"" + outputFilePath + "\"";
arguments += " /a";
arguments += " /dm1";
arguments += " /DL0";
arguments += " /a1";
arguments += " /h" + progressWindow.ClassId;
string ConverterPath = @"C:\Program Files\foo\bar\converter\go.exe"; // for
example
ProcessStartInfo psInfo = new ProcessStartInfo(ConverterPath, arguments);
psInfo.WindowStyle = ProcessWindowStyle.Hidden;
mProcess = Process.Start(psInfo);
The exception is observed on Windows 2000, but never on Windows XP. It works
fine on Windows 2000 if I never call the OpenFileDialog. I tried setting the
WorkingDirectory of the ProcessStartInfo instance to the directory that
contains the process executable, but this does not help.
Thanks,
Bret
I have an application that is launching a process (see the code below) to
perfom some operation on a file. On Windows 2000, if my application first
uses the OpenFileDialog to open a file on the desktop, Process.Start failes
with the following exception:
System.ComponentModel.Win32Exception: The system cannot find the file
specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo
startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
The code is roughly as follows:
// here we ask the user to open a file
OpenFileDialog openFileBox = new OpenFileDialog();
openFileBox.Filter = mAddFileFilter.ToString();
openFileBox.FilterIndex = 1;
if(openFileBox.ShowDialog() == DialogResult.OK) {
inputFilePath = openFileBox.FileNames;
}
// later we launch a process to perform an operation on the file
outputFilePath = System.IO.Path.GetTempFileName();
string arguments = "\"" + inputFilePath + "\" \"" + outputFilePath + "\"";
arguments += " /a";
arguments += " /dm1";
arguments += " /DL0";
arguments += " /a1";
arguments += " /h" + progressWindow.ClassId;
string ConverterPath = @"C:\Program Files\foo\bar\converter\go.exe"; // for
example
ProcessStartInfo psInfo = new ProcessStartInfo(ConverterPath, arguments);
psInfo.WindowStyle = ProcessWindowStyle.Hidden;
mProcess = Process.Start(psInfo);
The exception is observed on Windows 2000, but never on Windows XP. It works
fine on Windows 2000 if I never call the OpenFileDialog. I tried setting the
WorkingDirectory of the ProcessStartInfo instance to the directory that
contains the process executable, but this does not help.
Thanks,
Bret