Downloading from Winhost to user account

Discussion in 'General troubleshooting' started by Paul Rothenheber, Oct 1, 2014.

  1. I am currently trying to download an .exe using the following code:

    Dim setup AsString = "http://xxxxxxxxxxxxxxx.com/HTESPublish/setup.exe"
    Dim copyto AsString = "C:\HTESInc\setup.exe"
    If System.IO.File.Exists(copyto) Then
    IO.File.Delete(copyto)
    EndIf
    My.Computer.Network.DownloadFile(setup, copyto)

    The file is located withing the folder HTESPublish.

    I can run this from LocalHost and it downloads successfully. When I run it from Winhost, it does not recognize the file.

    Any one do a Download? If so can you share your vb.net code?

    Thanks
     
    Last edited by a moderator: Oct 14, 2015
  2. ComputerMan

    ComputerMan Winhost Staff

    I think you have to change the MIME Type of the exe file to: application/octet-stream

    By default it should already be set as application/octet-stream.

    You can do this using IIS Manager. Read our knowledge base article on how to connect to your site using IIS Manager here: https://support.Winhost.com/KB/a628/using-the-microsoft-iis-manager.aspx

    Once connected click on Double click on "MIME Types" icon in IIS Manager.

    Look for the extension ".exe" right click and select "Edit". Change the MIME Type to: application/octet-stream now click "OK".

    If the above information doesn't help what error message are you getting?
     
    Last edited by a moderator: Oct 14, 2015
    Michael likes this.
  3. The code I am using to download a .zip file is:

    Dim frm AsString = "http://preservemyculture.com/HTESZipMe.zip"
    Dim copyto AsString = "C:/HTESInc/HTESZip.zip"

    My.Computer.Network.DownloadFile(frm, copyto)

    If System.IO.File.Exists(copyto) Then
    tbmessage.Text = "File has been downloaded"
    EndIf

    When I run this I receive the message that "File has been downloaded". But I go to my C:/HTESInc/HTESZip.zip and it is not there? Weird.

    Is there a better way to download a .zip file from the WEBSITE?

    What could I be doing wrong????
     
  4. Elshadriel

    Elshadriel Winhost Staff

    Try changing this:

    Dim copyto AsString = "C:/HTESInc/HTESZip.zip"

    To:

    Dim copyto AsString = "C:\HTESInc\HTESZip.zip"

    You might need to escape the back slashes.
     
    Michael likes this.
  5. Tried everything

    Here is my current code

    Try
    Dim fileReader AsNewWebClient()
    Dim fileAddress = "http://preservemyculture.com/HTESPublish/HTESZipMe.zip"
    fileReader.DownloadFile(fileAddress, "C:HTESZipMe.zip")
    Catch ex AsException
    tbmessage.Text = ex.Message
    Finally
    tbmessage.Text = "It works"
    EndTry



    I get "It Works" but No file is downloaded to my C: Drive

    Any other ideas. Anyone have sample code that works for them??
     
  6. Elshadriel

    Elshadriel Winhost Staff

    You can take a look at the sample code here.
     
  7. I found a way using JavaScript to Download . thanks so much for your support on this matter.
     
    Elshadriel likes this.

Share This Page