Possible Duplicate:
Load an EXE file and run it from memory using C#
I am using the WebClient class to download a .exe from a web server. Is there a way that I can run the .exe without saving it to disk first?
For the purpose of completeness let me show you what I have so far.
Here is the code I use to start the download:
WebClient webClient = new WebClient();
webClient.DownloadDataCompleted += new DownloadDataCompletedEventHandler(webClient_DownloadDataCompleted);
webClient.DownloadDataAsync(new Uri("http://www.somewebsite.com/calc.exe"));
And in the (webClient_DownloadDataCompleted) method I simply grab the bytes from the parameter e:
private void webClient_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
Byte[] downloadedData = e.Result;
// how to run this like a .exe?
}
Thank you.