zoukankan      html  css  js  c++  java
  • c# 执行应用程序实例

            public static void DoRAR(string rarFile, string toRarDirecotry, string RARProgramFilePath)
            {
                string arguments = @"a -m0 -ep1 ""{0}"" ""{1}""";
                arguments = string.Format(
                    arguments,
                    rarFile,
                    toRarDirecotry
                );

                var proc = Process.Start(new ProcessStartInfo
                {
                    FileName = RARProgramFilePath,
                    Arguments = arguments,
                    UseShellExecute = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError = true,
                    RedirectStandardInput = true
                }
                );
                proc.WaitForExit();

                if (proc.ExitCode != 0)
                {
                    throw new Exception("Run WinRAR RAR Command Failed!, Exit Code: " + proc.ExitCode +
                        ", Details StandardOuput: " + proc.StandardOutput.ReadToEnd() +
                        ",StandardError" + proc.StandardError.ReadToEnd() +
                        ",StandardInput" + proc.StandardInput +
                        ",Site" + proc.Site);
                }
            }

  • 相关阅读:
    策略模式
    Properties类学习笔记
    System类学习笔记
    一个反射的妙用案例
    new 对象时的暗执行顺序
    常用数据库默认端口号
    java对日开发常用语(词汇)总结
    java开发中常用语(词汇)含义
    MyBatis 常用词汇含义
    java SE,EE,ME区别
  • 原文地址:https://www.cnblogs.com/doosmile/p/2726468.html
Copyright © 2011-2022 走看看