zoukankan      html  css  js  c++  java
  • c# 调用外部程序的例子

     

    #region 一个调用外部程序的例子
      private static string CmdPing(string strIp)
      {
       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 = true;
       string pingrst;
       p.Start();
       p.StandardInput.WriteLine("telnet 192.168.3.175 9944");
       p.StandardInput.WriteLine("quit");
       p.StandardInput.WriteLine("exit");
       string strRst = p.StandardOutput.ReadToEnd();
       Trace.WriteLine(strRst);
       p.Close();
       return pingrst;
       }
    #endregion

    习惯改为;private static string Cmd(string strcmd)
    {
     Process p = new Process();
     p.StartInfo.FileName = "cmd.exe /c"+strcmd;
     p.StartInfo.UseShellExecute = false;
     p.StartInfo.RedirectStandardInput = true;
     p.StartInfo.RedirectStandardOutput = true;
     p.StartInfo.RedirectStandardError = true;
     p.StartInfo.CreateNoWindow = true;
     p.Start();www.shengfang.org
     string strRst = p.StandardOutput.ReadToEnd();
     System.Diagnostics.Trace.WriteLine(strRst);
     p.Close();
     return strRst;
    }

  • 相关阅读:
    BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第11章节--为Office和SP解决方式开发集成Apps 集成SP和Office App
    jQuery 处理TextArea
    Raphael的拖动处理
    CSS的position设置
    SVG的内部事件添加
    SVG的a链接
    SVG的text使用
    SVG的path的使用
    SVG的Transform使用
    Java中两个List对比的算法
  • 原文地址:https://www.cnblogs.com/asyuras/p/278405.html
Copyright © 2011-2022 走看看