|
-
Apr 21st, 2009, 09:23 PM
#1
Thread Starter
Junior Member
File Downloader
Can anyone help me make a File Downloader?
What I'm trying to make is actually simple to most of the decent coders but I don't have enough experience to do this....
So what I want to make is a program that download all the files in a folder on a server.
But it has to check to see if it's going to download or not
and to check, what it does it compare 2 files
1) on the program side ( where the program is at )
2) on the server side
so it will read the 2 file
and if the 2 files are different then it will download all the files in a folder on the server and it will also download the file that it compared to with the one on the Program side.
Note* I do not want to download the folder, I want to download what's in the folder, every files inside the folder
And I would like to use a progress bar to show the progress of the download.
I also wanted to make a config file that customize the program
The config file can change the program like
background image
background color
title
size
text ( like labels and button names )
and etc
_____________________________________
Thanks alot if you can help
Last edited by PingPong; Apr 21st, 2009 at 09:34 PM.
-
Apr 23rd, 2009, 12:44 AM
#2
Thread Starter
Junior Member
-
Apr 23rd, 2009, 07:15 AM
#3
Re: File Downloader
that download all the files in a folder on a server
do you have the list of files or you just want to llop through all the files?
if you have a list of files you can easily use urldownload2file API
but if you need to loop through the files you would need FTP access and use ftp API or inet control to get the file list, i don't believe you can loop through files on most web servers
though you do not specify if it is a local server or internet server, so maybe i am making wrong assumptions
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 23rd, 2009, 05:31 PM
#4
Thread Starter
Junior Member
Re: File Downloader
Im going to host the files on my computer
so the server would be my computer
the files will change from time to time
( like different files will be put into the Updates folder.
So I have to use an ftp for it to look through the folder?
and how do I make the config file to edit the program?
-
Apr 24th, 2009, 03:26 AM
#5
Re: File Downloader
use an ini file, or just a basic textfile to save the settings you want to use
read the file in form load event and apply the saved settings
Im going to host the files on my computer
so the server would be my computer
are the people downloading doing on lan or internet?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 24th, 2009, 11:27 PM
#6
Thread Starter
Junior Member
Re: File Downloader
I got the config file down now
Now all I need to do is get the code to check if the ver number are the same or not.
( I can do this part, it's a lame way to do it but atleast it works )
Now what I need to do is get it to download ( using a button ) if the version number are different.
I want it to download all the Items in a specific folder. ( download items in it, Not The Folder )
And i want a progress bar to show the status....
-
Apr 25th, 2009, 03:59 AM
#7
Re: File Downloader
if your know the names of all the files in the directory, or you can list the files in the first file, the one you use to compare, you can loop through the list, without looping through the files in the folder, if that is the case the simplest method is to use urldownload2file API
example, comparison file
2.01
textfile.text
configfile.cfg
somefile.exe
Code:
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" _
Alias "DeleteUrlCacheEntryA" _
(ByVal lpszUrlName As String) As Long
Code:
Private Function DownloadFile(ByVal sURL As String, _
ByVal sLocalFile As String) As Boolean
Call DeleteUrlCacheEntry(sUrl)
DownloadFile = URLDownloadToFile(0, sURL, sLocalFile, 0, 0) = ERROR_SUCCESS
End Function
vb Code:
Dim myurl As String, fname As String, sSourceUrl As String, slocalfile As String Dim f As Integer, dlfail As Boolean, flist() As String myurl = "http://someurl.com/" fname = "verfile.txt" sSourceUrl = myurl & slocalfile slocalfile = app.Path & "\" & fname If downloadfile(sSourceUrl, slocalfile) Then f = FreeFile Open slocalfile For Input As f flist = Split(Input(LOF(f), #f), vbNewLine) Close f ' compare first line of file to some version number If flist(0) = app.major Then MsgBox "no need to upgrade": Exit Sub ' download all files in list in file ' if the last or any other line is empty will cause error For i = 1 To UBound(flist) If Not downloadfile(myurl & flist(i), app.Path & "\" & flist(i)) Then dlfail = True Next If dlfail Then MsgBox "some file failed to download correctly" End If
this is untested, you can use any variable to compare to ver# in file, needs some error handling, possibly list which file /s failed to download, if it vista do not use app.path
you can search on progress bar, there is many examples in the forum, if the files are of similar size just work it out on the number of files
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 25th, 2009, 02:21 PM
#8
Thread Starter
Junior Member
Re: File Downloader
I can check the file version now
All I need is a simple code that downloads every item in a specific folder
this is how I check the Version file
Have 2 Version.xml File on each side ( Host and Program )
When they click the button to check for updates, the button will make a richtextbox in form2 = to the Version.xml
Then it will read the server's xml file and make RichTextBox2 = to the server
and if those 2 = to each other then no download will be made
if it doesn't = to each other ( this is where Im stuck at ) then it download everything in a specific folder.
-
Apr 25th, 2009, 03:11 PM
#9
Re: File Downloader
If you have users using you app you may want to change how it works.
Have your online xml version compare to App.Minor or major. if you make a new version just change the online xml version. No need for a second client xml.
You can use
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Apr 25th, 2009, 06:49 PM
#10
Thread Starter
Junior Member
Re: File Downloader
 Originally Posted by isnoend07
If you have users using you app you may want to change how it works.
Have your online xml version compare to App.Minor or major. if you make a new version just change the online xml version. No need for a second client xml.
You can use
What?
I have the program compare the 2 files and it checks to see wether they are the same or not.
1 from program side and 1 from server
all I need now is to download and have a progressbar show the status
-
Apr 25th, 2009, 07:03 PM
#11
Re: File Downloader
 Originally Posted by PingPong
What?
I have the program compare the 2 files and it checks to see wether they are the same or not.
1 from program side and 1 from server
all I need now is to download and have a progressbar show the status
have you tried the code posted by westconn1 ?
Waiting for a full featured smart phone with out marrying a provider
Go Android
Go raiders 
-
Apr 25th, 2009, 07:13 PM
#12
Thread Starter
Junior Member
Re: File Downloader
I don't know where to put those
-
Apr 25th, 2009, 09:30 PM
#13
Re: File Downloader
I don't know where to put those
in a button click event or whatever other you want to start the progress
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|