Convert VB.Net Process Object Arguments to C#

I am trying to convert VB.Net Process object arguments to C#. Please help me resolve the errors.

This VB code works:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Dim startInfo As New ProcessStartInfo
        startInfo.FileName = "C:\Program Files (x86)\Visual CUT 11\Visual CUT.exe"
        startInfo.Arguments = "-e ""C:\test_3\People_1.rpt"" ""Export_Format:Adobe Acrobat (pdf)"" ""Export_File:C:\test_3\People_1.pdf"""
        Process.Start(startInfo)
    End Sub

Open in new window

This C# code contains the errors:
      psi.Arguments = "-e ""C:\\test_3\\People_1.rpt " +
            "Export_Format:Adobe Acrobat (pdf) " +
            "Export_File:C:\\test_3\\People_1.pdf"";

Open in new window

Full sub code:
       private void btnOpenPDF_Click(object sender, EventArgs e)
        {
            Process p = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.UseShellExecute = true;
            psi.FileName = "C:\\Program Files (x86)\\Visual CUT 11\\Visual CUT.exe";
            psi.Arguments = "-e ""C:\\test_3\\People_1.rpt " +
            "Export_Format:Adobe Acrobat (pdf) " +
            "Export_File:C:\\test_3\\People_1.pdf"";
            p.StartInfo = psi;
            p.Start();
        }

Open in new window

The following screenshot shows the C# errors:
Code Errors
Mark01Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chinmay PatelChief Technical NinjaCommented:
  psi.Arguments = "-e ""C:\\test_3\\People_1.rpt " +
            "Export_Format:Adobe Acrobat (pdf) " +
            "Export_File:C:\\test_3\\People_1.pdf"";

Open in new window


Change it to

psi.Arguments = string.Concat("-e ", "C:\\test_3\\People_1.rpt ", "Export_Format:Adobe Acrobat (pdf) ", "Export_File:C:\\test_3\\People_1.pdf");

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark01Author Commented:
No more build errors. Thank you, Chinmay Patel. Full code without build errors:
  private void btnOpenPDF_Click(object sender, EventArgs e)
        {
            Process p = new Process();
            ProcessStartInfo psi = new ProcessStartInfo();
            psi.UseShellExecute = true;
            psi.FileName = "C:\\Program Files (x86)\\Visual CUT 11\\Visual CUT.exe";
            psi.Arguments = string.Concat("-e ", "C:\\test_3\\People_1.rpt ", "Export_Format:Adobe Acrobat (pdf) ", "Export_File:C:\\test_3\\People_1.pdf");
            p.StartInfo = psi;
            p.Start();
        }
0
Fernando SotoRetiredCommented:
Try using this line in place of the one you have
psi.Arguments = "-e \"C:\\test_3\\People_1.rpt\" " + "\"Export_Format:Adobe Acrobat (pdf)\" " + "\"Export_File:C:\\test_3\\People_1.pdf\"";

Open in new window

0
Mark01Author Commented:
Fernando Soto: I get build errors from your code. Thank you for the code.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.