启动一个独立进程

//转换成swf  
           
            // 实例一个Process类,启动一个独立进程
            System.Diagnostics.Process p = new System.Diagnostics.Process();

            // 设定程序名
            p.StartInfo.FileName = "cmd.exe";

            // 关闭Shell的使用
            p.StartInfo.UseShellExecute = false;
            // 重定向标准输入
            p.StartInfo.RedirectStandardInput = true;
            // 重定向标准输出
            p.StartInfo.RedirectStandardOutput = true;
            //重定向错误输出
            p.StartInfo.RedirectStandardError = true;
            // 设置不显示窗口
            p.StartInfo.CreateNoWindow = true;
            // 启动进程
            p.Start();

            p.StandardInput.WriteLine(string.Format("{0}", System.Configuration.ConfigurationManager.AppSettings["flashpaperPF"]));
            p.StandardInput.WriteLine(string.Format(@"cd {0}", System.Configuration.ConfigurationManager.AppSettings["flashpaperLJ"]));
            p.StandardInput.WriteLine(string.Format(@"FlashPrinter.exe {0} -o {1}", uploadPath + fileName + "." + type, swfPath + fileName + ".swf"));
            p.StandardInput.WriteLine("exit");
            string strRst = p.StandardOutput.ReadToEnd();
            p.WaitForExit();
            p.Close();

posted @ 2012-07-09 15:50  顺手  阅读(191)  评论(0)    收藏  举报