日期:2014-05-18  浏览次数:20498 次

求解!!print2flash.exe asp.net中如何调用cmd.exe执行转化!!!
想做WORD转SWF,但是要部署在64位机器上,2003系统,之前做的flashpaper在XP上运行OK,但是不能运行在64位服务器上,只好用print2flash.exe,但是asp.net中的CMD调用命令不会写,求解asp.net中print2flash.exe的CMD调用转化命令,下面是我写的flashpaper转化代码。

public string Execute(string filepath,string type)
{

Process p = new Process();
string fileType = filepath.Substring(filepath.LastIndexOf('.') + 1).Replace(" ", "").ToLower();//文件类型

string outpath = "files/" + DateTime.Now.ToString("yyyyMMddHHmmssff") + ".swf";

if (File.Exists(outpath))
{
File.Delete(outpath);
}
if (fileType != "doc" && fileType != "xls" && fileType != "ppt" && fileType != "txt")
{
return string.Empty;
}
//将word转化为pdf
try
{
string fppath = System.Configuration.ConfigurationManager.AppSettings["FlashPaperPath"];
//fppath = Server.MapPath(fppath);
//string param = fppath + " " + filepath + " -o " + Server.MapPath(outpath);
string param = fppath + " " + filepath + " " + Server.MapPath(outpath);
string sys=Environment.SystemDirectory;

p.StartInfo.FileName = Environment.SystemDirectory+"\\cmd.exe";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
try
{
p.Start();
string strOutput = null;
p.StandardInput.WriteLine(param);
p.StandardInput.WriteLine("exit");
strOutput = p.StandardOutput.ReadToEnd();
Console.WriteLine(strOutput);
Thread.Sleep(5000);//等待转化
p.WaitForExit();
p.Close();
}
catch
{
return string.Empty;
}
if (!File.Exists(Server.MapPath("files/") + outpath.Substring(outpath.LastIndexOf('/') + 1).Replace(" ", "").ToLower()))//转化失败
{
return string.Empty;
}
}
catch
{
return string.Empty;
}
return outpath;
}

------解决方案--------------------
這是office to flash 全能控件

http://www.conaito.com/office-powerpoint-pdf-flash-openoffice-converter-sdk.asp
------解决方案--------------------
请先确定print2flash.exe在哪个文件夹下,也就是路径,比如绝对路径是path,然后
p.Start();
 string strOutput = null;
 p.StandardInput.WriteLine("cd "+path);
 p.StandardInput.WriteLine("print2flash.exe"+"其它参数");
 p.StandardInput.WriteLine("exit");
 p.WaitForExit();
 strOutput = p.StandardOutput.ReadToEnd();
 Console.WriteLine(strOutput);
 p.Close();

------解决方案--------------------
参考:http://topic.csdn.net/u/20110907/17/e893a7fb-d691-4db6-a19e-993bbe4b8da3.html