国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

C#調用CMD命令實例

2020-01-24 02:27:44
字體:
來源:轉載
供稿:網友

有時候有一些DOS命令需要我們在執行程序的時候調用,這需要使用C#提供的相關接口。

代碼如下,很簡單,相信大家都能看懂,我就不贅述了。

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Diagnostics;//這個是進行dos命令調用namespace ExecuteCMD{  //實現讀取Excel文件的功能  class ExecuteCMD  {    public static void CreateDll(){      Process p = new Process();      p.StartInfo.FileName = "cmd.exe";      p.StartInfo.UseShellExecute = false;      p.StartInfo.RedirectStandardInput = true;      p.StartInfo.RedirectStandardOutput = true;      p.StartInfo.RedirectStandardError = true;      p.StartInfo.CreateNoWindow = false;      p.Start();      p.StandardInput.WriteLine("systeminfo");      Console.Write(p.StandardOutput.ReadToEnd());      p.StandardInput.WriteLine("exit");    }  }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 太和县| 柳河县| 化州市| 高青县| 临潭县| 普洱| 温州市| 亚东县| 新疆| 连平县| 衡水市| 高青县| 绥宁县| 临颍县| 宁都县| 泰顺县| 突泉县| 大城县| 竹山县| 吐鲁番市| 彝良县| 大冶市| 靖边县| 鸡东县| 凤冈县| 财经| 瑞安市| 博白县| 会泽县| 安塞县| 收藏| 雅安市| 台山市| 方城县| 泰和县| 赤水市| 陆川县| 桃江县| 旺苍县| 凤山县| 佛坪县|