CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2009
    Posts
    27

    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?

  2. #2
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    47

    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

  3. #3
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    47

    Re: WriteAllBytes .exe problem

    Quote Originally Posted by boever View Post
    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

  4. #4
    Join Date
    Mar 2009
    Posts
    27

    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
  •  





Click Here to Expand Forum to Full Width

Featured