Exemplo n.º 1
0
        private void button_run_Click(object sender, EventArgs e)
        {
            string exeFilePath = this.fileOpenControl1.FilePath;

            string[] argsPathes = this.directorySelectionControl1.Pathes;

            foreach (var path in argsPathes)
            {
                if (File.Exists(path))
                {
                    ShowInfo("处理:" + path);
                    Geo.Common.ProcessRunner cmd = new Geo.Common.ProcessRunner(exeFilePath);
                    cmd.ExitedOrDisposed += cmd_ExitedOrDisposed;
                    cmd.Run(path);
                }
                if (Directory.Exists(path))
                {
                    var files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
                    foreach (var file in files)
                    {
                        if (File.Exists(file))
                        {
                            ShowInfo("处理:" + file);
                            Geo.Common.ProcessRunner cmd = new Geo.Common.ProcessRunner(exeFilePath);
                            cmd.ExitedOrDisposed += cmd_ExitedOrDisposed;
                            cmd.Run(path);
                        }
                    }
                }
            }

            MessageBox.Show("执行完毕!");
        }
Exemplo n.º 2
0
        private void button_runAsyn_Click(object sender, EventArgs e)
        {
            string cmdStr = this.textBox_cmd.Text;
            string result = helper.Run(cmdStr)[0];

            this.textBox_result.Text += result + "\r\n";
        }
Exemplo n.º 3
0
        public List <string> Decompress(string file, string destDir, bool delSource = false, bool overwrite = true)
        {
            Geo.Common.ProcessRunner cmd = new Geo.Common.ProcessRunner(exePath);
            cmd.ExitedOrDisposed += cmd_ProcessExited;
            // string str = exePath + " \"" + file + "\" " + "-f -s";
            string str = file + " -f -s";

            cmd.Run(str);

            if (delSource)
            {
                File.Delete(file);
            }
            List <string> result = new List <string>();

            //目标路径非相同
            if (!PathUtil.IsSamePath(destDir, Path.GetDirectoryName(file)))
            {
                //暂时没找到更能好的方法2013.03.01
                string[] files = Directory.GetFiles(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file) + "*");
                foreach (var item in files)
                {
                    if (String.Equals(file, item, StringComparison.CurrentCultureIgnoreCase))
                    {
                        continue;
                    }
                    string dest = Path.Combine(destDir, Path.GetFileName(item));

                    result.Add(dest);
                    if (File.Exists(dest))
                    {
                        if (overwrite)
                        {
                            File.Delete(dest);
                            File.Move(item, dest);
                        }
                    }
                    else
                    {
                        File.Move(item, dest);
                    }
                }
            }
            return(result);
        }