PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Download Files From Web With Progressbar - Page 2-VBForums
Page 2 of 4 FirstFirst 1234 LastLast
Results 41 to 80 of 132

Thread: Download Files From Web With Progressbar

  1. #41
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    hello people, this is my first post...
    First, best regards for kleinma, this is what i need for my project for school,
    i know that old thread but must try...

    i need to figure the whole core so i can adjust it and put in my project...
    here is a question:
    why i need this ??? it is a property ok, but in whe class it only use first line mCurrentFille, i didnt see the roll of property... i have remove it and it still works..... so why ? ))
    Code:
    Private mCurrentFile As String = String.Empty
    
        Public ReadOnly Property CurrentFile() As String
            Get
                Return mCurrentFile
            End Get
        End Property
    back to work... more questions to come ))
    i need to figure it out how to fix bug with "after close it still downloads"
    also for my project i need to download list of url's......... my app generates web urls and i need to download it all..... i need to figure it out how... maybe some loop...

    great work !!!

  2. #42

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    It is really just a helper property incase you want to access the name of the file being downloaded by the downloader class, from the code that calls the download.

    So in the example app, there is code in the form that handles the _Downloader.FileDownloadComplete event.

    It looks like this:
    Code:
        'FIRES WHEN DOWNLOAD IS COMPLETE
        Private Sub _Downloader_FileDownloadComplete() Handles _Downloader.FileDownloadComplete
            ProgBar.Value = ProgBar.Maximum
            MessageBox.Show("File Download Complete")
        End Sub
    However you could do something like this using that property:
    Code:
        'FIRES WHEN DOWNLOAD IS COMPLETE
        Private Sub _Downloader_FileDownloadComplete() Handles _Downloader.FileDownloadComplete
            ProgBar.Value = ProgBar.Maximum
            MessageBox.Show("File Download for " & _Downloader.CurrentFile & " Complete")
        End Sub
    Another option would be making a custom eventargs to pass to that event that includes the filename of the downloaded file instead, I just didn't make it that robust because I did not have a need to for the app I coded this for originally.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  3. #43
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    True True, thx for fast reply...
    i have put some check for URL that user type in...
    if user put http:// or if not, app will put...
    before that app report error... and user must type WHOLE url... and we know how users are )))))))))

    Code:
    in
        Private Sub cmdDownload_Click
            If Mid(txtURL.Text, 1, 7) <> "http://" Then
                Dim temp, http As String
                temp = txtURL.Text
                http = "http://"
                txtURL.Text = http & temp
            End If
    ------------- continue core
            'Download
            Try
                _Downloader = New WebFileDownloader
                _Downloader.DownloadFileWithProgress(txtURL.Text, txtDownloadTo.Text.TrimEnd("\"c) & GetFileNameFromURL(txtURL.Text))
            Catch ex As Exception
                MessageBox.Show("Error: " & ex.Message)
            End Try
        End Sub
    but i have one problem:
    i have form1, and on form1 i have button, when click form2 pop up...
    but if i close form1 form2 also will be closed... how can i make form2 stay?
    AND what is key word for checking IS FORM2 ACTIVE ? of IS FORM2 opened?

    thx
    SxOne
    Last edited by S-One; Jun 12th, 2008 at 08:33 AM.

  4. #44

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    What version of Visual Studio are you using?

    In 2005 and above, there is a setting in project properties which says "Shutdown Mode" and it is set to "When Startup Form Closes" by default.

    So if Form1 is your startup form, then closing it tells you app the whole thing should close. Change this value to "when last form closes" and that should solve your issue.

    Form.ActiveForm will return the active form anywhere inside your application. It is a shared property so no instance is required to use it. It can however return a value of Nothing, in the event there is no active form.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  5. #45
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    hehe i see what shutdown option in 2005 studio, but for this project i write in 2003 (((((((((( shame, i have converted to 2005 but design of app. is not like it need to be
    Code:
    Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterAllFormsClose
    ok for now i will use form2.showDialog() so thats ok for now
    thx for Form.ActiveForm but i think that i cant check if form2 is open, because if i try to close form1 and in "closing" event of form1 i put Form.ActiveForm Form1 will be active so must be something else.. but not important i will escape from that...

    thx Kleinma

  6. #46
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    hey do you have some idea how can i download more then one file from web... some loop
    actually let me explain...

    i have app that generates list of url's

    after that a need to download it all....
    i have an idea that maybe its best to put them in .txt file and forward it to your Download app.....

    i need to figure it how...
    out to work on it

  7. #47

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    I guess it depends on if you want to download one file at a time, or all of them at once. It was not really designed to perform multiple async downloads at the same time, however if you are just talking about downloading multiple files, one after another, then it could be as simple as making a list of files to download, and in the download complete event that fires off when a download has completed, you simply kick off the call to download the next file, until all files have been downloaded.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  8. #48
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    yes, i mean one file at a time, not multiple...
    thanks for idea, i will try that !!!

  9. #49
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    Quote Originally Posted by sdk1985
    Also there are some ! according to VB with the default project. (I am now using an exact copy of webfiledownloader.vb in my program)

    Warning 1 Variable 'FS' is used before it has been assigned a value. A null reference exception could result at runtime. I:\Documents and Settings\Sebas\Mijn documenten\Visual Studio 2005\Projects\FileTransfer\FileTransfer\WebFileDownloader.vb 70 21 FileTransfer

    Warning 2 Function 'FormatFileSize' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. I:\Documents and Settings\Sebas\Mijn documenten\Visual Studio 2005\Projects\FileTransfer\FileTransfer\WebFileDownloader.vb 99 5 FileTransfer
    Hmm, i have converter my project from .net 2003 to 2005 and i also get this Warning, weird, but there is return

    also i get warning abour DialogResult.no, yes, or whatever is used...
    i have resolved this with
    Code:
    System.Windows.Forms.DialogResult....
    EDIT:
    ok i have resolved FormatFileSize Warning Case else is missing:
    Code:
                    Select Case Size / KB
                        Case Is < 1000
                            Return (Size / KB).ToString("N") & "KB"
                        Case Is < 1000000
                            Return (Size / MB).ToString("N") & "MB"
                        Case Is < 10000000
                            Return (Size / MB / KB).ToString("N") & "GB"
                        Case Else
                            Return Size.ToString & "bytes"
                    End Select
    Matt can you explain this please ("D" & "N" is format right):
    Size.ToString("D") .ToString("N")
    also cant find help about URL.IndexOf("/"c) and URL.LastIndexOf("/"c)
    what is c for ? (description is Char, but please explain

    thx in advance !
    Last edited by S-One; Jun 14th, 2008 at 09:29 PM.

  10. #50

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    Quote Originally Posted by S-One
    Hmm, i have converter my project from .net 2003 to 2005 and i also get this Warning, weird, but there is return

    also i get warning abour DialogResult.no, yes, or whatever is used...
    i have resolved this with
    Code:
    System.Windows.Forms.DialogResult....
    EDIT:
    ok i have resolved FormatFileSize Warning Case else is missing:
    Code:
                    Select Case Size / KB
                        Case Is < 1000
                            Return (Size / KB).ToString("N") & "KB"
                        Case Is < 1000000
                            Return (Size / MB).ToString("N") & "MB"
                        Case Is < 10000000
                            Return (Size / MB / KB).ToString("N") & "GB"
                        Case Else
                            Return Size.ToString & "bytes"
                    End Select
    Matt can you explain this please ("D" & "N" is format right):
    Size.ToString("D") .ToString("N")
    also cant find help about URL.IndexOf("/"c) and URL.LastIndexOf("/"c)
    what is c for ? (description is Char, but please explain

    thx in advance !
    Yeah this project was originally done in VS2003 (.NET 1.1) they added in some warnings in the newer versions of VS, so that is what you were seeing.

    Those fixes you made were fine.

    "D" is for decimal formatting of a number as a string, and "N" is for general number formatting of a number as a string. In some cases, they may yield the same result, and in others they will not. (usually has to do with number of decimal place precision, etc..)

    Here is a listing of valid numeric formats for calling ToString
    http://msdn.microsoft.com/en-us/libr...9k(VS.80).aspx

    The IndexOf method is a method that simply returns the numeric index of where a given character is in a string of characters.

    So given the string "abccba", the character positions of the letters are as follows:

    a = 0
    b = 1
    c = 2
    c = 3
    b = 4
    a = 5

    So if I were to get the indexof("a"c), it will return 0, as a is found at position 0 in this string, however getting lastindexof("a") does the same thing, but starts at the end of the string, in which case it will find a in position 5, so it will return a 5.

    the c after the specified character is just to tell the compiler "this is a datatype char, not a string with only 1 character". By default VB thinks anything in quotes is a string.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  11. #51
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    thanks Matt !!!
    great answer !!!

  12. #52
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    Hey Matt, can i ask for one more thing, can you help me how to delete file that didnt whole downloaded, i made Cancel button but cant figure it out where to put delete method, and which is a delete method...

    is this enough to Flush all buffers from memory or need something more ?
    Code:
                    If Cancel = True Then
                        sChunks.Close()
                        FS.Close()
                        FS = Nothing
                        RaiseEvent CancelResetLabelText()
                        Return False
                    End If
    this is in "DownloadFileWithProgress" Do While Loop
    i need this for school project so if you can please help me...

  13. #53
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    i have resolved problem with deleting non downloaded file.

    In "DownloadFileWithProgress" function in Do While Loop, i have added Cancel option before and in that part i have added this line:
    My.Computer.FileSystem.DeleteFile(Location.ToString)

    [code]
    Do
    If Cancel = True Then
    sChunks.Close()
    FS.Close()
    FS = Nothing
    My.Computer.FileSystem.DeleteFile(Location.ToString)
    RaiseEvent CancelResetLabelText()
    Return False
    End If
    .................
    [code]

    it works great file is deleted if it's canceled, so now my project is finished... i will post Screenshots later...
    thanks again matt for Help, and fot this application !!!!!!!!!!!
    Best Regards,
    ShOne from Serbia

  14. #54
    Lively Member
    Join Date
    Dec 2007
    Posts
    99

    Re: Download Files From Web With Progressbar

    superb script.

    Quick question, is it possible to modify to download a web folders contents as opposed to a file???

    cheers

  15. #55

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    it downloads the file over HTTP, so if you knew the specific file names, then of course you could run it in a loop and download each file.

    If you mean can you point it to a folder location on the web, and have it download every file without knowing their names, then no. A webserver doesn't serve up the list of files in a given folder unless directory browsing is on. If directory browsing was on, you could in theory navigate to the directory, parse the list of files, and then download them individually because you would now have their names.

    If you were to go a different route, like FTP if it were possible for you, then you can do things like list the contents of a directory without downloading anything, and then download the entire directories contents.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  16. #56
    Lively Member
    Join Date
    Dec 2007
    Posts
    99

    Re: Download Files From Web With Progressbar

    wow that was quick

    I have director browsing installed and I only want to use it for small files but many of them.

    I'm new so please be gently

    What do I need to do to get the directory downloaded

    again many thanks

  17. #57

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    you would want to download the HTML that is output by your webserver when you visit that page, and parse it to get the file names. Once you have each individual file name in a collection or an array, then you could use my code in this thread to loop and download each file.

    You should really start a new thread in the VB.NET section of this forum, asking about downloading and parsing a file list from a website with directory browsing on.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  18. #58
    Lively Member
    Join Date
    Dec 2007
    Posts
    99

    Re: Download Files From Web With Progressbar

    Matt,

    Will do thanks for directing me in the right direction.

    Your script is a real diamond

  19. #59

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    Check back soon, I am working on a new version which has a few extra features.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  20. #60
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    Hey Matt, me again
    Can you explain to me why did you wrote this line ?
    Dim myWebResponse As WebResponse = myWebRequest.GetResponse

    i understand first part, but why did you initializes it ?? and what did you get with it ?
    also this line same question
    Dim myStream As Stream = myWebResponse.GetResponseStream

    thx in advance...
    Sxone
    Last edited by S-One; Sep 3rd, 2008 at 04:31 PM.

  21. #61

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    You don't get a response from your request to download a file until you call the GetResponse method. When you do that, the response is returned from the class as a WebResponse object.

    So that line of code
    Dim myWebResponse As WebResponse = wRemote.GetResponse

    is saying

    Declare myWebResponse as a WebResponse object and set it to the response from the WebRequest called myWebRequest.

    So once you create your webrequest to download the file, you need to check the response. That is how the stateless nature of the web works, through requests from you and responses from web servers.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  22. #62
    New Member S-One's Avatar
    Join Date
    Jun 2008
    Posts
    11

    Re: Download Files From Web With Progressbar

    Niiice
    thanks very much...
    if there is something i can do for you, like Upload something, ANYTHING, just say, you have helped me a lot with your example and code support
    i have use some of your code in my project (like i sad before) for school, it is over, but i need to write report, so i'm learning how does it works...

    maybe i will ask you something more, if i need :P
    thanks a lot again
    SxOne

  23. #63

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    I just post on here to help out so others can learn how to program too. I love VB so I always like to help out those who are learning it.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  24. #64
    Hyperactive Member
    Join Date
    Jun 2008
    Posts
    493

    Re: Download Files From Web With Progressbar

    Ya the code works but there is one problem first of all it takes about five seconds before the message shows saying "Connection Found!" Second of all it freezes after the message comes up it wont allow any buttons to be clicked! I am using Microsoft Visual Basic 2008 Windows XP SP2

  25. #65
    Addicted Member
    Join Date
    Mar 2006
    Posts
    242

    Re: Download Files From Web With Progressbar

    hia sorry mate for User login section i didn't get erectly..

    can u assist me how can i make users that download files from Rapidshare or megaupload or mxupload to be able to log with their premium account..
    < advertising link removed by moderator >

  26. #66

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    you should open a new thread in the VB.NET section on that. Questions here should only pertain to the specific code in the codebank submission.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  27. #67
    Addicted Member
    Join Date
    Mar 2006
    Posts
    242

    Re: Download Files From Web With Progressbar

    is your download manager you had made just want to add User login to that download manager thets all...
    < advertising link removed by moderator >

  28. #68

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    those file services require HTTP form based logins, so your actual question really should be how to perform that authentication prior to using my download code.

    That is what belongs in its own thread. This web file downloader example code I have posted here is for non password protected file downloads.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  29. #69
    New Member
    Join Date
    Nov 2008
    Posts
    5

    Re: Download Files From Web With Progressbar

    Hi, It's really a gem of Code. I need some help. How to show the estimated time, elapsed time, time remaining, etc when the file is downloading?

  30. #70
    New Member
    Join Date
    Nov 2008
    Posts
    5

    Re: Download Files From Web With Progressbar

    I have a situation where i have two buttons and on clicking button1 i can download abc.rar and on clicking button2 i can download xyz.rar. I used your webfiledownloader class. Now my problem is that before the abc.rar is downloaded completely i clicked on button2 which will start downloading xyz.rar by stopping abc.rar. How to make xyz.rar to wait till abc.rar is finished?

  31. #71
    New Member
    Join Date
    Nov 2008
    Posts
    5

    Question Re: Download Files From Web With Progressbar

    How to show estimated time, remaining time, download speed, etc when the file is downloading in this WebFileDownloader class?

  32. #72
    Addicted Member
    Join Date
    May 2008
    Location
    Denmark
    Posts
    178

    Re: Download Files From Web With Progressbar

    ehm...

    I get this error in the DownloadFileWithProgress function;

    vb.net Code:
    1. FS = New FileStream(Location, FileMode.Create, FileAccess.Write)
    2.  
    3. "Access to the path 'C:\' was denied"

    Im running win xp, and there's only one user and it got full admin rights...

  33. #73

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    what is the actual value of the "Location" variable when that occurs?

    Also, can the user manually create a file on the root of C?
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  34. #74
    New Member
    Join Date
    Nov 2008
    Posts
    5

    Re: Download Files From Web With Progressbar

    How to show estimated time, remaining time, download speed, etc when the file is downloading in this WebFileDownloader class?

  35. #75

    Thread Starter
    Moderator.NET kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,383

    Re: Download Files From Web With Progressbar

    you would need to calculate all those things on your own. You should develop each forumla first, like time remaining is an estimate based on the amount currently downloaded, the total file size, and the download speed.

    I haven't worked these types of features into this code, but feel free to work it in, and post back with your results.
    Using VS.NET 2013/.NET 2.0 through 4.5 * Please mark you thread resolved using the Thread Tools above
    PLEASE INDICATE WHAT VERSION OF VB YOU USE!!!!!!!!!!!
    * If you found a post useful then please Rate it! * DO NOT PM ME WITH LINKS TO YOUR THREADS FOR ANSWERS PLEASE!

    Code Bank:Manipulate HTML Page content in the Web Browser Control from VB - Drag Drop from Windows into Win Form - Launch new default browser instance to open URL - Display Internet Image in Picturebox - Download Files From Web With Progress Bar - IP Textbox User Control - Installing .NET Framework with INNO Setup
    ZerosAndTheOne.com
    -=Matt=-

  36. #76
    Hyperactive Member
    Join Date
    Jun 2008
    Location
    Nowhere
    Posts
    427

    Re: Download Files From Web With Progressbar

    Kleinma could you help me to get this to report progress please? It uses .NetWebrequest as in your class.
    Also is there any downfalls to using this?

    vb.net Code:
    1. Public Class Form1
    2.     Private Const filenames As String = "c:\Users\Home\Desktop\list_of_files.txt"
    3.     Private Const url As String = "http://www.fileden.com/files/2008/12/22/2233952"
    4.     Private Const savepath As String = "c:\Users\Home\Desktop\"
    5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.         Try
    7.             Dim sr As New IO.StreamReader(filenames)
    8.             Dim line As String = sr.ReadLine()
    9.             Dim req As Net.WebRequest
    10.             Dim resp As IO.Stream
    11.             Dim out As IO.BinaryWriter
    12.             Do While line IsNot Nothing
    13.                 req = Net.HttpWebRequest.Create(url & line)
    14.                 resp = req.GetResponse().GetResponseStream()
    15.                 out = New IO.BinaryWriter(New IO.FileStream(savepath & line, IO.FileMode.OpenOrCreate))
    16.                 Dim buf(4096) As Byte
    17.                 Dim k As Int32 = resp.Read(buf, 0, 4096)
    18.                 Do While k > 0
    19.                     out.Write(buf, 0, k)
    20.                     k = resp.Read(buf, 0, 4096)
    21.                 Loop
    22.                 resp.Close()
    23.                 out.Close()
    24.                 line = sr.ReadLine()
    25.             Loop
    26.         Catch i As Exception
    27.             MsgBox(i.ToString)
    28.         End Try
    29.     End Sub
    30. End Class
    "Programming is like sex. One mistake and you have to support it for the rest of your life." ~Michael Sinz


    Code Snippets/Usefull Links:
    WinRAR DLL|Vista Style Form|Krypton Component Library|Windows Form Aero|Parsing XML files|Calculate File's CRC 32|Download a list of files.

  37. #77
    Addicted Member
    Join Date
    May 2008
    Location
    Denmark
    Posts
    178

    Re: Download Files From Web With Progressbar

    Quote Originally Posted by kleinma
    what is the actual value of the "Location" variable when that occurs?

    Also, can the user manually create a file on the root of C?
    Sorry for being so late, i totally forgot this. I have gotten a new hd lately (christmas), and it still says the same thing.

    i changed the path to "C:\Documents and Settings\Steffenn\Skrivebord", still gets access denied.

    also tried C:\, same.

  38. #78
    New Member
    Join Date
    Jan 2009
    Posts
    6

    Re: Download Files From Web With Progressbar

    Thank you for posting this example. I've been looking for ways to download large files with a look like you created.

    So far I've tested this to handle up to 480 MB with no problems

  39. #79
    New Member
    Join Date
    Nov 2008
    Posts
    5

    Re: Download Files From Web With Progressbar

    Thanks for your advice. I will try it on my own.


    Quote Originally Posted by kleinma
    you would need to calculate all those things on your own. You should develop each forumla first, like time remaining is an estimate based on the amount currently downloaded, the total file size, and the download speed.

    I haven't worked these types of features into this code, but feel free to work it in, and post back with your results.

  40. #80
    New Member
    Join Date
    Jan 2009
    Posts
    4

    Re: Download Files From Web With Progressbar

    hey, i am having some problems making the cancel button. I used the code provided by s-one:
    Code:
    Do
    If Cancel = True Then
    sChunks.Close()
    FS.Close()
    FS = Nothing
    My.Computer.FileSystem.DeleteFile(Location.ToString)
    RaiseEvent CancelResetLabelText()
    Return False
    End If
    how would i call this with a button? what do you need to declare in the frmmain.vb and webfiledownloader.vb? thanks...

Page 2 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width