public static void TransformFile(string filepath)
{
string fppath = System.Configuration.ConfigurationManager.AppSettings["Flashpaper"];
string outpath = filepath.Substring(0, filepath.LastIndexOf(.)) + ".swf";
string param = fppath + " " + filepath + " -o " + outpath;
Process p = new Process();
p.StartInfo.FileName = "C:\WINDOWS\system32\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);
p.WaitForExit();
p.Close();
}
catch (Exception ex)
{
throw ex;
}
}
注意:如果不能正常操作,是權限的問題,以iis 為例,請把IUSR_xxx授權到讀寫的文件夾。