Run Command Prompt Commands

前端 未结 14 1893
暖寄归人
暖寄归人 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:21

    Here is little simple and less code version. It will hide the console window too-

    System.Diagnostics.Process process = new System.Diagnostics.Process();
    process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
    process.StartInfo.FileName = "cmd.exe";
    process.StartInfo.Arguments = "/C copy /b Image1.jpg + Archive.rar Image2.jpg";
    process.Start();
    

提交回复
热议问题