网站一个功能是上传txt、doc、xls等文件并转化flash文件,用的是flashpaper2软件转化。
flashpaper2的转化命令是:flashpaper2.exe 1.dox -o 1.swf
我是先把这个命令写入一个bat文件,在执行bat文件,这样可以避免留下进程。
这是写bat文件的代码
- C# code
switch (extensionFilename) { case "doc": case "xls": case "txt": FileStream batFile = new FileStream(Server.MapPath("del.bat"), FileMode.Truncate); StreamWriter sw = new StreamWriter(batFile); string flashpaper2path = linq.Information.Single(i => i.Name == "flashpaper2path").Contents; sw.Write(flashpaper2path + " " + originalFile + " -o " + flashFile); //sw.Write("del C:\\Users\\Administrator\\Desktop\\1.txt"); //sw.Write("C:\\Windows\\system32\\notepad.exe"); sw.Close(); batFile.Close(); ToFlash(); newfile.FileRead = true; break; default: newfile.FileRead = false; break; }
这是转化为flash的代码
- C# code
protected void ToFlash() { System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); psi.FileName = Server.MapPath("del.bat"); //psi.UseShellExecute = false; //psi.CreateNoWindow = true; System.Diagnostics.Process.Start(psi); }
现在的问题是:上传txt文档,可以顺利的转化为flash文档,而且没有留下进程,但是上传doc文档时,不能生产flash文档,并且留下了flashPrint进程(即flash转化软件的进程),cmd进程,winword进程。如果我手动运行bat文件,却能生成flash文档,我猜想是权限问题,或者是系统的设置问题(应用程序设置问题)。
请高手解决。
------解决方案--------------------------------------------------------
看你的代码没有问题。
我记得以前有这么样的一个问题 也是调用不好使 手动好使 找不到了。- -!