Search code examples
c#stringquotation-marks

Quotation mark and slash mark in C# string


I want to execute a cmd command in C#. Below command AAA is working in Windows 10 cmd. The below code's string AAA part is not the correct format in C#. How can I change this cmd command into correct C# string format?

System.Diagnostics.Process process = new System.Diagnostics.Process();
            process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            process.StartInfo.FileName = "cmd.exe";
            string AAA= "curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "@xxx.json" "https://some.org/api/oauth/token"";
            process.StartInfo.Arguments = AAA;

Solution

  • put @ in front of the string and use double qoutes.

    string AAA = @"curl -X POST --header ""Content-Type: application/json"" --header ""Accept: application/json"" -d ""@xxx.json"" ""https://some.org/api/oauth/token""";