How do I download a file and run it automatically immediately after download is completed?
How do I download a file and run it automatically immediately after download is completed?
You can't do that anymore.
At one time browsers did allow you to say click on a download link, and then choose run.
but, these days, for reasons of security, it not really possible - and this ability is controlled by the browser settings, and not your asp.net web site code.
It simply too high of a security risk. So, when you download a file?, then users will have to open their download folder, and choose run in most cases.
I've tried using System.Diagnostics.ProcessStartInfo but it doesn't find the file FileName = @"MyExe.exe";
System.Diagnostics.ProcessStartInfo info = new ProcessStartInfo();
info.FileName = @"MyExe.exe";
info.Arguments = "";
info.WindowStyle = ProcessWindowStyle.Normal;
Process pro = Process.Start(info);
pro.WaitForExit();
I've got it to work... Here is the code.
string toolsDir = System.Web.Hosting.HostingEnvironment.MapPath(ToolsDir);
string toolexe = Path.Combine(toolsDir, ToolName);
ProcessStartInfo psi = new ProcessStartInfo(toolexe);
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.CreateNoWindow = true;
psi.Arguments = "-d:Dummy";
Process p = Process.Start(psi);
5 people are following this question.