使用来自mvc应用程序的输入文件调用exe

时间:2017-11-23 07:10:23

标签: c# asp.net-mvc exe

我正在调用exe程序,当调用时需要inputfile.txt并且它在同一文件夹中生成outputfile.txt。 exe工作正常。

现在我想在Web应用程序中转换同样的东西但是我遇到了问题。

我使用的代码如下

// Prepare the process to run
           ProcessStartInfo start = new ProcessStartInfo();
           // Enter in the command line arguments, everything you would enter after the executable name itself
           start.Arguments = @"C:\Program Files\AET_Calculator\application\InputFile.txt"; ;
           // Enter the executable to run, including the complete path
           start.FileName = @"C:\Program Files\AET_Calculator\application\AET_Calculator.exe";
           // Do you want to show a console window?
           start.WindowStyle = ProcessWindowStyle.Hidden;
           start.Verb = "runas";
           start.UseShellExecute = true;
           int exitCode;


           // Run the external process & wait for it to finish
           using (Process proc = Process.Start(start))
           {
               proc.WaitForExit();

               // Retrieve the app's exit code
               exitCode = proc.ExitCode;
           }

它的投掷错误。如何通过输入txt文件

从Web应用程序调用exe

这是我得到的错误: enter image description here

1 个答案:

答案 0 :(得分:0)

您需要.exe文件中的{strong>授予执行访问权限给IIS中的用户将用于访问该文件,大部分时间是应用程序池标识或在IIS IIS_WPG用户中。{/ p>