zoukankan      html  css  js  c++  java
  • 调用系统工具代码

    调用系统的工具,并可以实现回调处理核心代码:

    public static class DOS
    {
    public static void CMD(
    string commandNameOrFileName,
    string arguments,
    DataReceivedEventHandler callback)
    {
    try
    {
    Process process = new Process();
    process.StartInfo.FileName = commandNameOrFileName;
    process.StartInfo.Arguments = arguments;
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardInput = true;
    process.StartInfo.RedirectStandardOutput = true;
    process.StartInfo.RedirectStandardError = true;
    process.StartInfo.CreateNoWindow = true;
    process.OutputDataReceived += new DataReceivedEventHandler(callback);
    process.Start();
    process.BeginOutputReadLine();
    process.WaitForExit();
    process.Close();
    }
    catch (Exception ex)
    {
    LogHelper.WriteError("调用系统失败", ex);
    throw new ArgumentException("打开工具失败!", ex);
    }
    }
    }

  • 相关阅读:
    12.Scala- 注解
    11.Scala-特质
    10.Scala-继承
    9.Scala- 包和引入
    8.Scala-对象
    7.Scala-类
    6.Scala-高阶函数
    5.Scala-匹配模式
    4.Scala-数据结构
    Ruby on Rails Tutorial 第四章 Rails背后的Ruby 之 类
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/3419057.html
Copyright © 2011-2022 走看看