VB Downloader. Download files from the web, with prog bar.
There are 2 downloader projects attached here. 1 asynchronous project and 1 synchronous project.
The synchronous downloader, vbDownloader.zip, uses the URLDownload API and uses call backs to allow the user to cancel the download and/or show a prog bar.
For this project to work you need to do the following:
Attached is code, plus a demo app, that allows you to download files from the web.
This can be used for auto updates for a client exe etc, or just as a download manager.
and extract the 2 tlb files and install them using the instructions provided.
These tlb files are used for the call back to allow the download to be shown in a progress bar, and to allow the user to cancel the download.
The 2nd project "Downloader and Winsock.zip" is an asynchronous downloader that uses a DLL version of the winsock control.
This has a few benefits over the URLDownload method. 1stly it's asynchronous and there you can have multiple downloads at any one time in your app, plus it allows you to use your app while downloading. It also allows you to get the file size of the file before you download it. This I find is very usefull.
However, the URLDownload example allows you to cache the file in the internet cache folder....this can be handy. The winsock does not cache any of the file, and if the download is aborted cancelled you will have to download the whole file from scratch.
Pick ya method
Woka
Last edited by Wokawidget; Apr 15th, 2005 at 03:33 AM.
Re: VB Downloader. Download files from the web, with prog bar.
Nice code, worked fine for me in the IDE. But when I compiled both files (vbWebDownload.dll and DemoDownloadApp.exe) the app didn't work anymore. When trying to download a file the app hangs and after a while says 'Download aborted. Resource not found.' Without error handler it gave me a 'Object variable or With block variable not set' error and an Automation error. Does this happen with anyone else when the app is compiled?
Re: VB Downloader. Download files from the web, with prog bar.
When you copyied both the tlb files to system32, did you register them using the instructions on the web site, or did you just browse to the files in VB and register them that way?
Just asking as that's the only thing I can think of off the top of my head.
Will have a go myself tomorrow to see if I can crash it.
Re: VB Downloader. Download files from the web, with prog bar.
Sorry...but no more downloading for you...my domain went out today...I have a backup of your files though. And I can upload it as fast as I get the new server up and running if you want that....
Re: VB Downloader. Download files from the web, with prog bar.
Oppps....well let me continue in the wrong thread then...
I have my new host, more or less up and running, some countries might not reach it before a day or two. But at least it is up again. You might have to check if it is still working though. I don't know squat about DNS and stuff...but it is somehow chaned, but the name is still the same, just the IP that has changet I guess.
Re: VB Downloader. Download files from the web, with prog bar.
Thanks for your quick response. I have gotten it working now and really like how well it works. Not completely sure how to integrate the code into my project though. Can I just copy the frmMain code into my project and reference the vbwebdownload.dll?
Re: VB Downloader. Download files from the web, with prog bar.
Nice one.
Yup. Just copy frmMain into your app then ref the dll.
Although I would suggest looking at the winsock method, as it's aysnchronous, which has much wider benefits.
Re: VB Downloader. Download files from the web, with prog bar.
Hey,
i know its abit late in the day for this thread but just incase sum1 cares.
I was having trouble getting the winsock version working, constantly getting an error 53, turns out it raises an error if the file you want to download doesnt already exist on your computer
adding a copy where you want to download gets around this but seemed like a funny thing to raise an error about. It downloads and overwrites existing file anyway.(might want to add user warning/input to this) :P
Re: VB Downloader. Download files from the web, with prog bar.
Originally Posted by TheVader
Nice code, worked fine for me in the IDE. But when I compiled both files (vbWebDownload.dll and DemoDownloadApp.exe) the app didn't work anymore. When trying to download a file the app hangs and after a while says 'Download aborted. Resource not found.' Without error handler it gave me a 'Object variable or With block variable not set' error and an Automation error. Does this happen with anyone else when the app is compiled?
Hope i can get an answer to this old thread. I am having the same problem works good in ide but compiled exe gives me the same error you stated:
download aborted resource not found
Did you ever get a fix?
Re: VB Downloader. Download files from the web, with prog bar.
Hi WOKA,
I used your vbDownloader project using OLE and it works great for me!!
Thanks for that!!!!
But though there is a big problem that How can I use it to download multiple files from my URL?
I'm using VB6 and downloading Images from my URL. And I need to download multiple files at the same time the process started for any file.
As I'm not able to understand how to use the OLE Interfaces I request for the resources to understand that properly and useful for Development.
Re: VB Downloader. Download files from the web, with prog bar.
You need to use the Download Code + Winsock download from my 1st post and create multiple downlaod classes...or combine my multithreading code with the OLE downloading code.
Personally I would go for the 1st option as this is already async.
Re: VB Downloader. Download files from the web, with prog bar.
i know this is an old thread but i just came across it. using the non winsock version it works just as i need it to but the issue i have is what if we dont know the file name to be used? like getting files from a php page? the filename is unkown thus no idea what to save it as
Re: VB Downloader. Download files from the web, with prog bar.
cause you dont know what file your grabbing. its a php script and by entering in a random number it sends you a file but it could be a jpg gif you just dont know. so what im basicly looking to do is send the link then using a for loop on a set number range to enter in the numbers i want. then it download the file. i tried making use of the internet controls but it works just like if i was using a webbrowser and some files like jpg get opened within the browser instead. if the download box would just open for all files i could easily use api to manipulate the box
Re: VB Downloader. Download files from the web, with prog bar.
It is always good to give people credit where credit is due.
So as woka says, he offers his code up for free for anyone to use because he is a nice guy. So if you use his code and it saves you a lot of time, its always nice to give him a little credit in your about screen or readme file.
Re: VB Downloader. Download files from the web, with prog bar.
Thank you Woka!
Of course I'll credit you on my project.
About the error that raises every time I try to download a file, let me explain:
Every time I click the "get file info" button, i got a success message, telling me the size of the file.
Every time I click the "download file" button the application raises error 53, telling me that the file doesn't exist... that is correct because is the first time I try to download it.
I see the error raises on the OpenFile() subroutine, but I don't know how to fix it. Would you please help me, dear Woka? If you try to replicate this behaivor you must delete the file in the download directory, because if it exists before the download begins and no error will be raised.
Re: VB Downloader. Download files from the web, with prog bar.
Hi Woka!
The project is: "Downloader and Winsock" located at http://www.vbforums.com/showthread.p...hreadid=310235 Which line is happening on: is on the sub OpenFile() on Download.cls What file is trying to open: I really don´t know, because no file have been downloaded yet Does the path Exist: yes, it exists.
The download works ok, now I made the call from a new form inside the same project, but the connection can´t be made. I created a new object "download" and applied it´s methods, It starts the connection but It can´t success.
How the download object must be used from another form within the project?
Re: VB Downloader. Download files from the web, with prog bar.
Upss...!
It´s my failure... I tried to connect to a site which was up at certain time, but for some reason this site went down exactly when I tried the connection using the new form. Your program works correctly.