日期:2014-05-18 浏览次数:21016 次
protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string filename = FileUpload1.FileName;
                //string extension=Path.GetExtension(filename);  //获取后缀名
                string file_name = filename.Substring(0, filename.LastIndexOf("."));//获取不含扩展名的文件名
                string file_storage = Server.MapPath("~/File/storage/") + filename; //原文件存放的路径
                FileUpload1.SaveAs(file_storage);
                string file_bowze = Server.MapPath("~/File/bowze/") + file_name + ".swf"; //转换为SWF格式后存放的路径
                string flash_file = Server.MapPath("~/FlashPaper2.2/FlashPrinter.exe");
                Process pro = new Process();
                pro.StartInfo.FileName = "cmd"; //调用CMD线程
                pro.StartInfo.UseShellExecute = false;
                pro.StartInfo.RedirectStandardInput = true;  //注册输入指向
                pro.StartInfo.RedirectStandardOutput = true;  //注册输出指向
                pro.StartInfo.CreateNoWindow = true; //不建新窗口,这个属性可以根据需要自己设定
                pro.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;  //隐藏窗口
                pro.Start();
                string input = string.Format("{0} {1} -o {2}", flash_file, file_storage, file_bowze);  //类似于在DOS界面要输入的内容
                pro.StandardInput.WriteLine(input); //将内容写到DOS   ---个人是这么理解的
                pro.StandardInput.WriteLine("exit");
                pro.WaitForExit(600000);
                string output = pro.StandardOutput.ReadToEnd(); //这句一定要加,输出转换好的SWF格式文件到指定位置 ,我一开始没加怎么都得不到文件
                pro.Close(); //关掉线程
            }
        }
private void button2_Click(object sender, EventArgs e)
        {
            string flash_file = Application.StartupPath + "\\FlashPaper2.2\\FlashPrinter.exe";
            string file_storage = Application.StartupPath + "\\2.doc";
            string file_bowze = Application.StartupPath + "\\2.swf";
            Process pro = new Process();
            pro.StartInfo.FileName = "cmd"; //调用CMD线程
            pro.StartInfo.UseShellExecute = false;
            pro.StartInfo.RedirectStandardInput = true;  //注册输入指向
            pro.StartInfo.RedirectStandardOutput = true;  //注册输出指向
            pro.StartInfo.CreateNoWindow = true; //不建新窗口,这个属性可以根据需要自己设定
            pro.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;  //隐藏窗口
            try
            {
                pro.Start();
                string input = string.Format("{0} {1} -o {2}", flash_file, file_storage, file_bowze);  //类似于在DOS界面要输入的内容
                pro.StandardInput.WriteLine(input); //将内容写到DOS   ---个人是这么理解的
                pro.StandardInput.WriteLine("exit");
                pro.WaitForExit(600000);
                string output = pro.StandardOutput.ReadToEnd(); //这句一定要加,输出转换好的SWF格式文件到指定位置 ,我一开始没加怎么都得不到文件
                pro.Close(); //关掉线程
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }