Run Command Prompt Commands

前端 未结 14 1957
暖寄归人
暖寄归人 2020-11-21 05:32

Is there any way to run command prompt commands from within a C# application? If so how would I do the following:

copy /b Image1.jpg + Archive.rar Image2.jp         


        
14条回答
  •  旧巷少年郎
    2020-11-21 06:16

    None of the above answers helped for some reason, it seems like they sweep errors under the rug and make troubleshooting one's command difficult. So I ended up going with something like this, maybe it will help someone else:

    var proc = new Process
    {
        StartInfo = new ProcessStartInfo
        {
            FileName = @"C:\Program Files\Microsoft Visual Studio 14.0\Common7\IDE\tf.exe",
            Arguments = "checkout AndroidManifest.xml",
            UseShellExecute = false,
            RedirectStandardOutput = true,
            CreateNoWindow = true,
            WorkingDirectory = @"C:\MyAndroidApp\"
        }
    };
    
    proc.Start();
    

提交回复
热议问题