asp.net通过bat文件调用word程序
网站一个功能是上传txt、doc、xls等文件并转化flash文件,用的是flashpaper2软件转化。
flashpaper2的转化命令是:flashpaper2.exe 1.dox -o 1.swf
我是先把这个命令写入一个bat文件,在执行bat文件,这样可以避免留下进程。
这是写bat文件的代码
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; } 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); }