Azure应用服务,运行本机EXE来转换文件 [英] Azure App Service, run a native EXE to convert a file
问题描述
我有一个本机EXE,可以根据命令行参数转换文件.提供的,我知道如何给输入和输出文件提供完整的路径名,当按下某个按钮并等待创建输出文件时,我可以从我的应用程序服务中运行这样的EXE吗?不能转换为DLL.
I have a native EXE that converts a file based on command line arguments. Provided, I know how to give full path names of the input and output files, can I run such an EXE from my app service when some button is pressed and wait till the output file is created? Converting to DLL is not an option.
推荐答案
据我所知,我们可以在azure应用服务中运行本机exe.
As far as I know, we could run a native exe in the azure app service.
但是我们无法将参数直接传递给本机exe.
But we couldn't directly pass the parameter to the native exe.
您需要编写一个Web应用程序或其他内容供用户键入输入参数.
You need write a web application or something else for the user to type in the input parameter.
Then you could use Process.Start method to run the exe.
关于操作方法,您可以参考此代码示例.
About how to do it , you could refer to this code sample.
我使用ASP.NET MVC获取输入参数,然后将参数发送到exe并获取结果.
I use ASP.NET MVC to get the input parameter then send the parameter to the exe and get the result.
public ActionResult Index()
{
var proc = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = Server.MapPath("/exe/Sum.exe"),
//Arguments could be replaced
Arguments = "1 2",
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
proc.Start();
while (!proc.StandardOutput.EndOfStream)
{
string line = proc.StandardOutput.ReadLine();
// do something with line
Response.Write( " The result is : " + line);
}
//await getResultAsync();
return View();
}
结果:
这篇关于Azure应用服务,运行本机EXE来转换文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!