WriteAllBytes .exe problem
Hi,
I am trying to copy and .exe to a clients computer and then execute it.
Code:
System.Net.WebRequest request = System.Net.WebRequest.Create("http://users.telenet.be/Helaas/BvrMemClient.exe");
using (System.Net.WebResponse response = request.GetResponse())
{
using (System.IO.Stream stream = response.GetResponseStream())
{
byte[] content = new byte[response.ContentLength];
stream.Read(content, 0, content.Length);
System.IO.File.WriteAllBytes("C:\\Documents and Settings\\Tomas\\BvrMemClient.exe", content);
}
}
Process.Start("C:\\Documents and Settings\\Tomas\\BvrMemClient.exe");
This code writes the BvrMemClient.exe to the given directory.
But this new file is not executable, although it has the same bytes.
How can I get this to work?
Any advice?
Re: WriteAllBytes .exe problem
**Accidentally double post, please check my reply below**
Re: WriteAllBytes .exe problem
Quote:
Originally Posted by
boever
How can I get this to work?
Any advice?
Could you try to use System.Net.WebClient instead? It has a method called "DownloadFile".
Check this out: http://msdn.microsoft.com/en-us/libr...ds(VS.80).aspx
Re: WriteAllBytes .exe problem
Thanks alot , it worked !! <3