none
Network.DownloadFile - Empty File RRS feed

  • Question

  • Hello everyone,

    I am trieng to download a file with the Network.DownloadFile option.

    But I have a problem. Every file I download is empty.

    Here is my code:

    CheckLink = "http://www.mediafire.com/download/s57v5u87txkacc8/Test.txt"
    CheckFileDestination = Program.Directory + "\\Test.txt"
    CheckFile = Network.DownloadFile(CheckLink)
    File.CopyFile(CheckFile, CheckFileDestination)

    The file will be created, but it is empty everytime. If I download it manualy it is not empty.

    Any suggestions?


    Mit freundlichen Grüßen Timo Greetings Timo

    Saturday, August 10, 2013 2:44 PM

Answers

  • Timo, I think it's the website you're downloading from.

    'url = "http://www.mediafire.com/download/wmm1w2o1xoo2gr5/ducks.jpg"
    url = "http://www.bowlingballs.us/images/bowling-ball-480.jpg"
    pic = ImageList.LoadImage(url)
    GraphicsWindow.DrawImage(pic,0,0)
    I've tried this with other accounts and they don't seem to let you d/load straight from a url. Only links. Maybe they don't want people using it as a personal website, just a file service. If anyone knows of a file service you can do this from I'd love to know what it is.
    • Proposed as answer by litdevModerator Sunday, August 11, 2013 1:16 PM
    • Marked as answer by Timo Sö Sunday, August 11, 2013 1:46 PM
    Sunday, August 11, 2013 6:33 AM
    Moderator

All replies

  • Here is a bit of code that works. I could not get your code to compile, so I'm not sure what else is there.

    Imports Microsoft.VisualBasic.Devices
    
    Module Module1
        private _checkFileDestination as String
        private _checkFile as Object
        private _checkLink as String
    
        Sub Main()
            CheckLink = "http://www.mediafire.com/download/s57v5u87txkacc8/Test.txt"
            CheckFileDestination = "Test.txt"
            Dim network  = New Network
            network.DownloadFile(CheckLink, CheckFileDestination)
        End Sub
    
        Public Property CheckLink() As String
            Get
                Return _checkLink
            End Get
            Set(ByVal value As String)
                _checkLink = value
            End Set
        End Property
    
        Public Property CheckFile() As Object
            Get
                Return _checkFile
            End Get
            Set(ByVal value As Object)
                _checkFile = value
            End Set
        End Property
    
        Public Property CheckFileDestination() As String
            Get
                Return _checkFileDestination
            End Get
            Set(ByVal value As String)
                _checkFileDestination = value
            End Set
        End Property
    End Module


    Gil Yoder<br/> Application Performance Analyst

    Saturday, August 10, 2013 3:03 PM
  • Hello Gil Yolder,

    thanks for your code.

    You yoused Visual Basic. But I used Small Basic. That is why you can't compile it.

    And so your code isn't very useful for me (I can't use Visual Basic).


    Mit freundlichen Grüßen Timo Greetings Timo

    Saturday, August 10, 2013 3:15 PM
  • I've had trouble with this as well. There's nothing in the temp file.
    Sunday, August 11, 2013 2:36 AM
    Moderator
  • Odd--- I can't get it to work either. The temp file is created but nothing is being written to it--- according to what I see in ILSpy, that means that it is not throwing an exception anywhere down the line. 

    If I were you, I would take a look around and see there is an extension that can download your file.


    Please mark any answers and "vote as helpful" any posts that help you!

    Sunday, August 11, 2013 3:44 AM
    Answerer
  • Timo, I think it's the website you're downloading from.

    'url = "http://www.mediafire.com/download/wmm1w2o1xoo2gr5/ducks.jpg"
    url = "http://www.bowlingballs.us/images/bowling-ball-480.jpg"
    pic = ImageList.LoadImage(url)
    GraphicsWindow.DrawImage(pic,0,0)
    I've tried this with other accounts and they don't seem to let you d/load straight from a url. Only links. Maybe they don't want people using it as a personal website, just a file service. If anyone knows of a file service you can do this from I'd love to know what it is.
    • Proposed as answer by litdevModerator Sunday, August 11, 2013 1:16 PM
    • Marked as answer by Timo Sö Sunday, August 11, 2013 1:46 PM
    Sunday, August 11, 2013 6:33 AM
    Moderator
  • this works using Network but only on sites that aren't File Services.

    'url = "http://www.mediafire.com/download/wmm1w2o1xoo2gr5/ducks.jpg"
    url = "http://www.bowlingballs.us/images/bowling-ball-480.jpg"
    tmpFile = Network.DownloadFile(url)
    File.CopyFile(tmpFile, "C:\Temp\bowlingball.jpg")
    filePath = "C:\Temp\bowlingball.jpg"
    pic = ImageList.LoadImage(filePath)
    GraphicsWindow.DrawImage(pic,0,0)
    Sunday, August 11, 2013 6:47 AM
    Moderator
  • I think you are right Jibba Jabba.

    I will ask my brother if it is possible to create a website where I can host a file which has the same link(after every upload).


    Mit freundlichen Grüßen Timo Greetings Timo

    Sunday, August 11, 2013 1:47 PM
  • I just remembered that I had a similar problem with downloading files from the internet in SB a couple of years ago. Here is how I solved it:

    1) Put a copy of WGET in the program's directory

    2) Call WGET from the command line to download the file with a switch to make the site think that WGET is actually a web browser (http://ubuntuincident.wordpress.com/2012/03/28/download-files-with-wget-from-sites-that-verify-your-user-agent/)

    Then wait for WGET to complete and your file should be in the directory!


    Please mark any answers and "vote as helpful" any posts that help you!

    Sunday, August 11, 2013 2:11 PM
    Answerer
  • I tried Data extension.   It returned the contents.

    CheckLink = "http://www.mediafire.com/download/s57v5u87txkacc8/Test.txt"
    CheckFileDestination =  "D:\Test.txt"
    NetworkPlus.DownloadFile(CheckLink ,CheckFileDestination)


    * Is this right contents?
    Sunday, August 11, 2013 2:50 PM
    Answerer
  • I tried Data extension.   It returned the contents.

    CheckLink = "http://www.mediafire.com/download/s57v5u87txkacc8/Test.txt"
    CheckFileDestination =  "D:\Test.txt"
    NetworkPlus.DownloadFile(CheckLink ,CheckFileDestination)


    * Is this right contents?

    No it is not the right content.

    The right content would be

    1.0
    1
    http://www.mediafire.com/download/58exxshn2s2e9mb/Note_Program.txt

    But I get the web page contents or something similar.

    I will try your other suggestion. But what is WGET?


    Mit freundlichen Grüßen Timo Greetings Timo


    • Edited by Timo Sö Sunday, August 11, 2013 4:22 PM
    Sunday, August 11, 2013 4:21 PM
  • WGET is a popular file downloader that originally was developed for Linux. It has been ported to Windows and can be called from the command line. You can get it here: http://gnuwin32.sourceforge.net/packages/wget.htm 

    What I think is happening here is that the website is detecting that your program is not a web browser and refuses the request. WGET can trick the site by telling it that it is a web browser (with a command line switch.)


    Please mark any answers and "vote as helpful" any posts that help you!

    Sunday, August 11, 2013 4:40 PM
    Answerer
  • Ah thanks.

    But then, WGET is no option for me (but i will test it for later projects), because I want create an auto updater snippet. And this should not need a seperate program.

    My brother told me that it is possible to host a file on an own website without that the ink changes if I update the file. So I will try this as soon as he is back at home.

    But thanks for your help. :)


    Mit freundlichen Grüßen Timo Greetings Timo

    Sunday, August 11, 2013 4:45 PM
  • Oh. Thanks. This could be handy.
    Sunday, August 11, 2013 8:52 PM
    Moderator