我有一个从命令行调用的 exe。是否可以在服务器上执行该文件?在计算机上,如果文件位于文件夹 abc 中,我将转到文件夹 abc,然后执行批处理。我如何在 C# 中执行此操作
最佳答案
下面的代码示例,请确保您的权限设置正确:
System.Diagnostics.Process yourProcess = new System.Diagnostics.Process();
// Set the directory
yourProcess.StartInfo.WorkingDirectory = Request.MapPath("~/"); //or wherever your file is
// Set the filename
yourProcess.StartInfo.FileName = Request.MapPath("bla.exe");
// Start the process
yourProcess.Start();
关于c# - 在服务器上执行一个 EXE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8282454/