Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Code today gone tomorrow!
Posted

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

Code today gone tomorrow!
  • 2 months later...
Posted

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

Posted

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

Posted

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

  • 2 months later...
Posted (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 by rgreen

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...