示例#1
0
文件: CmdHelper.cs 项目: kooera/vli
 private void OutputDataReceived(object sender, DataReceivedEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.Data))
     {
         string str = "[" + DateTime.Now.ToString() + "]    " + e.Data;
         DirFileHelper.WriteFile(logName, str);
     }
 }
示例#2
0
文件: CmdHelper.cs 项目: kooera/vli
        public CmdHelper()
        {
            string dir = Environment.CurrentDirectory + "\\cmdLog\\";

            if (!dir.EndsWith("\\"))
            {
                dir = dir + "\\";
            }
            logName = DirFileHelper.CreateDirectory(dir) + DateTime.Now.ToString("yyyyMMddhhmmssfffff") + ".log";
            proc    = new Process();
        }
示例#3
0
文件: CmdHelper.cs 项目: kooera/vli
        public CmdHelper(string logPath)
        {
            if (logPath.EndsWith("\\"))
            {
                logName = DirFileHelper.CreateDirectory(logPath) + DateTime.Now.ToString("yyyyMMddhhmmssfffff") + ".log";
            }
            else
            {
                logName = DirFileHelper.CreateDirectory(logPath) + "\\" + DateTime.Now.ToString("yyyyMMddhhmmssfffff") + ".log";
            }

            proc = new Process();
        }
示例#4
0
文件: CmdHelper.cs 项目: kooera/vli
        public void Execute(string cmd, out string msg)
        {
            msg = "";
            proc.StartInfo.CreateNoWindow         = true;
            proc.StartInfo.FileName               = "cmd.exe";
            proc.StartInfo.UseShellExecute        = false;
            proc.StartInfo.RedirectStandardInput  = true;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.RedirectStandardError  = true;
            proc.Start();

            if (!string.IsNullOrEmpty(cmd))
            {
                proc.StandardInput.WriteLine(cmd.TrimEnd('&') + "&exit");
                proc.StandardInput.AutoFlush = true;
            }
            msg = proc.StandardOutput.ReadToEnd();

            proc.WaitForExit();
            proc.Close();

            DirFileHelper.WriteFile(logName, msg + "\n end");
        }