Run Command Prompt Commands

前端 未结 14 1917
暖寄归人
暖寄归人 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 05:59

    This can also be done by P/Invoking the C standard library's system function.

    using System.Runtime.InteropServices;
    
    [DllImport("msvcrt.dll")]
    public static extern int system(string format);
    
    system("copy Test.txt Test2.txt");
    

    Output:

          1 file(s) copied.
    

提交回复
热议问题