Saturday, March 24, 2012

Open a file from ASP.NET

Hello to you all,
How can i open a file from asp.net, for example an pdf, or exe?

Hi,

Do you want to launch an exe from your web app? Is this what u r asking.? If yes.. u can try the following

string ProcessLocation = System.Configuration.ConfigurationManager.AppSettings["ProcessLocation"].ToString().Trim();

ProcessStartInfo processinfo =newProcessStartInfo(ProcessLocation,"arugments that u want to pass");

Process MyProcess=newProcess();

MyProcess.StartInfo = processinfo;

MyProcess.Start();

This would launch any exe for you. Please note that this would cause the exe to be run under the same accnt as your web application. So make sure you have sufficient permissions if your exe has to do any IO operations. The aspnet user by default will NOT have permissions to do all this. So might want you web app to impersonate some account.

Hope this helps

Thanks,

0 comments:

Post a Comment