C# System Cannot Find File Specified Error

I’m trying to write some simple C# code in a winform app that gets the same results as a VB.Net sub. Please help me correct the error. The following VB (in a winform app) code runs without any errors:

Dim retval As String
Dim ls_temp As String
ls_temp = "C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe " & _
"-e ""C:\test\Email_Test_1aa.rpt"""
retval = Shell(ls_temp)

The following C# code results in a "The system cannot find the file specified" error:

using System.Diagnostics;

string retval;
string ls_temp;

retval = "C:\\Program Files (x86)\\Visual CUT 11\\Visual CUT.exe " + "-e " + "C:\\test\\Email_Test_1aa.rpt";

Process runScripts = new Process();
runScripts.StartInfo.FileName = @"""C:\Program Files (x86)\Visual CUT 11Visual CUT.exe""";
runScripts.StartInfo.UseShellExecute = true;
runScripts.StartInfo.RedirectStandardOutput = false;
Who is Participating?

Improve company productivity with a Business Account.Sign Up

Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
aren't you missing a \ on that line:
runScripts.StartInfo.FileName = @"""C:\Program Files (x86)\Visual CUT 11Visual CUT.exe""";

Open in new window

I think it should be:
runScripts.StartInfo.FileName = @"""C:\Program Files (x86)\Visual CUT\11Visual CUT.exe""";

Open in new window

Mark01Author Commented:
That resolved the error. The app, Visual Cut, does not perform the desired action, as it does when the VB code is run. All that happens is the following command line runs:
C:\Program Files (x86)\Visual CUT\11Visual CUT.exe

However, the following command line does not run:

Any ideas?
Éric MoreauSenior .Net ConsultantCommented:
but you never pass your retval to runscripts!

Add this line
runScripts.StartInfo.Arguments = "C:\\test\\Email_Test_1aa.rpt"

Open in new window

Have a look at http://emoreau.com/Entries/Articles/2003/12/The-Process-component.aspx
Mark01Author Commented:
Thank you, Eric.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.