当用户单击某个链接时,我的网站运行一个本地.exe文件(生成一些数据)。
我想知道如何做以下工作
我使用.net 4 c#
发布于 2011-03-06 09:38:46
下面是我在其中一个应用程序中使用的东西:
var p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.FileName = HttpContext.Current.Server.MapFfmpegPath();
p.StartInfo.Arguments = "arguments go here :)";
p.Start();
p.WaitForExit();至于可执行文件本身,我在项目中创建了一个目录,并将exe放在该目录中。MapFfmpegPath方法如下所示。
public static string MapFfmpegPath(this HttpServerUtility server)
{
return "\"" + server.MapPath("/CoolPathHere/ffmpeg.exe") + "\"";
}发布于 2011-03-06 08:23:00
不确定这在MVC中是否有效,但请尝试一下:
// Process class resides in System.Diagnostics namespace
Process myProcess = Process.Start("...");
myProcess.WaitForExit();
// todo : process your datahttps://stackoverflow.com/questions/5209447
复制相似问题