Process.StartInfo

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.
 
R

Rajeev Goel

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.
 
R

Richard Mayer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top