在C#里,如何执行cmd里的常用dos命令 (转)
http://blogger.org.cn/blog/more.asp?name=nrzj&id=4280
?
using System;
using System.Diagnostics;
namespace Tipo.Tools.Utility
{
?/// <summary>
?/// 常用Dos命令操作
?/// </summary>
?public class DosCommand
?{
??private Process process=null;
??private string _errmsg;
??public DosCommand()
??{
???process = new Process();
???process.StartInfo.FileName = "cmd.exe";
???process.StartInfo.UseShellExecute = false;
???process.StartInfo.RedirectStandardInput = true;
???process.StartInfo.RedirectStandardOutput = true;
???process.StartInfo.RedirectStandardError = true;
???process.StartInfo.CreateNoWindow = false;
???process.Start();
??}
??//檢測文件或目錄是否存在
??public string exist(string path)
??{
???process.StandardInput.WriteLine(string.Format("dir \"{0}\"",path));
???process.StandardInput.WriteLine("exit");
???_errmsg = process.StandardError.ReadToEnd();
???return _errmsg;
??}
?}
}
轉(zhuǎn)載于:https://www.cnblogs.com/marssl/archive/2009/01/16/1377350.html
總結(jié)
以上是生活随笔為你收集整理的在C#里,如何执行cmd里的常用dos命令 (转)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何优雅的快速下载谷歌云盘的大文件 (二
- 下一篇: c# char unsigned_dll