运行命令提示符命令 [英] Run Command Prompt Commands
本文介绍了运行命令提示符命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法从C#应用程序中运行命令提示符下的命令?如果是的话我会怎样做到以下几点:
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.jpg
这基本上嵌入JPG图片内的RAR文件。我只是想知道是否有一种方法,在C#中自动执行此操作。谢谢你。
This basically embeds an RAR file within JPG image. I was just wondering if there was a way to do this automatically in C#. Thank you.
推荐答案
这是所有你必须从C#做的运行shell命令
this is all you have to do run shell commands from C#
string strCmdText;
strCmdText= "/C copy /b Image1.jpg + Archive.rar Image2.jpg";
System.Diagnostics.Process.Start("CMD.exe",strCmdText);
编辑:
这是隐藏cmd窗口。
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C copy /b Image1.jpg + Archive.rar Image2.jpg";
process.StartInfo = startInfo;
process.Start();
这篇关于运行命令提示符命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文