![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; string strpath = MapPath(@"~AppAcmeCADConverter");//放在站点目录不用设置过多的权限 string stroutpath = MapPath(@"~Out"); //输出目录也放在站点下面 string strinpath = MapPath(@"~Infiles"); //文件也放在站点目录下面 string commandText = strpath + @"AcmeCADConverter /r /e /w 1280 /h 800 /f 2 /d " + stroutpath + " " + strinpath + "test.dwg"; //要执行的cmd命令 p.Start(); p.StandardInput.WriteLine(commandText); p.StandardInput.WriteLine("exit"); p.WaitForExit(); p.Close(); Response.Write("执行完成");
为了执行方便,我们把所有文件都放在站点目录下,这样不需要设置过多的权限
https://files.cnblogs.com/techMichaelLee/WebTest.rar