|
-
May 3rd, 2009, 11:21 AM
#1
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?
-
May 3rd, 2009, 11:32 AM
#2
Re: WriteAllBytes .exe problem
**Accidentally double post, please check my reply below**
Last edited by xander_tan; May 3rd, 2009 at 11:35 AM.
Xander Tan
-
May 3rd, 2009, 11:34 AM
#3
Re: WriteAllBytes .exe problem
 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
Xander Tan
-
May 3rd, 2009, 04:27 PM
#4
Re: WriteAllBytes .exe problem
Thanks alot , it worked !! <3
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|