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);
    }
    }
    }

  • 相关阅读:
    Git
    vue
    vue
    echarts,dojo和兼容问题
    js数组对象以某一对象排序
    滚动条与图片移动
    vue
    vue
    vue页面组件化-父子组件传值
    phpquery笔记
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/3419057.html
Copyright © 2011-2022 走看看