Process.StartInfo

  • Thread starter Thread starter Richard Mayer
  • Start date Start date
R

Richard Mayer

After using a OpenFileDialog to locate a file within
Visual Studio.Net, A System.Diagnostics.Process is created
and the file information set using StartInfo. The process
returns an error indicating the File cannot be found
although the file is available and the working directory
has been set. If the OpenFileDialog is not used and the
path to the file is set directly the process is started
and works fine. This is repeatable and fails every time.
It appears to be a bug. Any suggestions would be
appreciated.
 
Hi Richard,

The following code worked for me:

OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();

ProcessStartInfo startInfo = new ProcessStartInfo(ofd.FileName);
Process proc = Process.Start(startInfo);

proc.WaitForExit();

This allowed me to select a file using the Open File dialog, and then it
correctly launched the process. Could you post the snippet of code that
you're using, which is causing a problem?

Thanks,
Rajeev
Visual Studio .NET
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks for the reply,

The exact same code does not work on my machine. If I do the
ProcessStartInfo without doing the OpenFileDialog first (hard coding the
path), it works. I'm using .Net Framework v1.0.3705
 
Back
Top