a_jam_sandwich Posted January 29, 2003 Posted January 29, 2003 for those of you looking to create Live updaters and were wondering how heres so code me and tHe_cLeanER have put together with progress bar support and saving to files. Function DownloadChunks(ByVal sURL As String, ByVal pProgress As ProgressBar, ByVal Filename As String) Dim wRemote As System.Net.WebRequest Dim URLReq As HttpWebRequest Dim URLRes As HttpWebResponse Dim FileStreamer As New FileStream(Filename, FileMode.Create) Dim bBuffer(999) As Byte Dim iBytesRead As Integer Try URLReq = WebRequest.Create(sURL) URLRes = URLReq.GetResponse Dim sChunks As Stream = URLReq.GetResponse.GetResponseStream pProgress.Maximum = URLRes.ContentLength Do iBytesRead = sChunks.Read(bBuffer, 0, 1000) FileStreamer.Write(bBuffer, 0, iBytesRead) If pProgress.Value + iBytesRead <= pProgress.Maximum Then pProgress.Value += iBytesRead Else pProgress.Value = pProgress.Maximum End If Loop Until iBytesRead = 0 pProgress.Value = pProgress.Maximum sChunks.Close() FileStreamer.Close() Return sResponseData Catch MsgBox(Err.Description) End Try End Function Should be fairly easy to understand, Ill have a program soon as a Live Updater in test at the mo. It will support versioning from a standard HTTP server :) sURL is where your requesting your download from e.g. 'www.mysite.com/files/' filename is the file your downloading 'myprogram.exe' incase you were wondering Quote Code today gone tomorrow!
a_jam_sandwich Posted January 29, 2003 Author Posted January 29, 2003 Ive come to a BIG problem Downloading from the LAN connection works great Donwloading from a modem (Only One Though) come up with the error (403) access to this page is forbiddon Anyone Help Quote Code today gone tomorrow!
a_jam_sandwich Posted January 29, 2003 Author Posted January 29, 2003 No matter down to the sevice provier have a firewall and being a general pain in the arse Quote Code today gone tomorrow!
a_jam_sandwich Posted January 30, 2003 Author Posted January 30, 2003 Live Updater Here the program comments welcome :) Andyupdater.net.zip Quote Code today gone tomorrow!
russgreen Posted April 5, 2003 Posted April 5, 2003 This is a great bit of code.... I want to implement it into my app but I'll have multiple files to update and not always the same files. Can this work on whole folders? ie look at a folder on my website and download the entire contents of that folder. If not do you know how hard it would be to unzip and zip file automatically when it has finished downloading? Russ Quote Learn Visual Studio .Net My Homepage
russgreen Posted April 5, 2003 Posted April 5, 2003 OK I miss understood the files. Wow. This really is good code.. I am getting errors though when trying to use subfolders. Can someone just clarify how its supposed to work if I need to put a file in a subdirectory on the local machine ? I have this as my update.dat file but it genrates errors. [VERSIONLIST] VERSION=1.2.2 updateinformation=Welcome to the updater for Project Database Suite [uPDATELIST] # If the version is > 1 e.g. 1.0.1 - 1.0.0 = 1 where 1.0.1 is download version then download # all files marked FILE# *numbers must be in sequence* # you can include subfolders e.g. myfolder/myfile the subfolder is the folder located on the # computer being downloaded to NOT the HTTP server #FILE1=<FILENAME> #FILE2=<FILENAME> #FILE3=<FILENAME> #FILE4=<FILENAME> FILE1=lists/folders.lst # If the version is > 1 e.g. 1.0.2 - 1.0.0 = 2 where 1.0.1 is download version then download # all files marked FILE-UPDATE# *numbers must be in sequence* #FILE-UPDATE1=<FILENAME> #FILE-UPDATE2=<FILENAME> #FILE-UPDATE3=<FILENAME> #FILE-UPDATE4=<FILENAME> FILE-UPDATE1=folders.lst # Created by Andrew Duff, (C) 2003 This is the line in the log file... 05/04/2003 15:46:54 ERRROR Could not find a part of the path "D:\Development Resources\Downloads\Updater.Net\bin\TEST\Downloading_lists\folders.lst"., 76 Russ Quote Learn Visual Studio .Net My Homepage
a_jam_sandwich Posted April 5, 2003 Author Posted April 5, 2003 Have you checked the Folder exists? Quote Code today gone tomorrow!
russgreen Posted April 5, 2003 Posted April 5, 2003 I figured that one out as well. It did work when the folder existed. I'm going to try to extend your code if you don't mind. I want to be able to create folders, delete files and possible executre ReadMe files when a user updates the app. It should only be a small extension to make all that possible though. Russ Quote Learn Visual Studio .Net My Homepage
a_jam_sandwich Posted April 5, 2003 Author Posted April 5, 2003 (edited) Its there to be changed if you look out on http://www.codeconcepts.co.uk Ill be adding controls there including a control for downloading a lot more user friendly than this app Btw post your code once your done and share the wealth Andy Edited April 6, 2003 by a_jam_sandwich Quote Code today gone tomorrow!
rgreen Posted June 8, 2003 Posted June 8, 2003 (edited) I have been working on an extended version of LiveUpdater that includes the ability to create local folders, delete local files and execute a downloaded file. Its also uses xml rather than ini and dat. It's early days but you can get it here Download project here Its a little buggy, but I'm working on it. Edited June 8, 2003 by rgreen Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.