Click to See Complete Forum and Search --> : Update function help


raulh
October 29th, 2008, 06:53 PM
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lbl1.Text = ("Parsing file...")
Dim baseDir As New DirectoryInfo(Application.ExecutablePath)
Dim update As ugen.Update = ugen.Update.Parse("linkhere")
For Each file As ugen.UpdateFile In update.Files
Dim fi As New FileInfo(baseDir.FullName + file.FilePath)
If (fi.Exists) Then ' its supposed to be if it exists check if it doesnt exist just update it
Dim size As Integer = fi.Length
Dim hash As String = makeHash(fi)
If size <> file.Size Or hash <> file.Hash Then
update(file)

End If
Else
update(file)
End If

Next
End Sub
End Class

Namespace ugen
Public Class Update
Public Files As New List(Of UpdateFile)()

Public Sub New()
End Sub
Public Shared Function Parse(ByVal url As String) As Update
Dim data As String = New WebClient().DownloadString(url)
Dim update As New Update()
Dim lines As String() = data.Split(New String() {vbCr & vbLf}, StringSplitOptions.RemoveEmptyEntries)
For Each line As String In lines
Try
Dim infos As String() = line.Split(New Char() {"|"c})
Dim name As String = infos(0)
Dim size As Integer = Integer.Parse(infos(1))
Dim hash As String = infos(2)
update.Files.Add(New UpdateFile(name, size, hash))
Catch
End Try
Next
Return update
End Function
End Class
Public Class UpdateFile
Private _filepath As String, _hash As String
Private _size As Integer = -1
Public Sub New(ByVal filepath As String, ByVal size As Integer, ByVal hash As String)
_filepath = filepath
_size = size
_hash = hash
End Sub
Public Property FilePath() As String
Get
Return _filepath
End Get
Set(ByVal value As String)
_filepath = value
End Set
End Property
Public Property Hash() As String
Get
Return _hash
End Get
Set(ByVal value As String)
_hash = value
End Set
End Property
Public Property Size() As Integer
Get
Return _size
End Get
Set(ByVal value As Integer)
_size = value
End Set
End Property
End Class
End Namespace

i need a little help coding the update function and makehash function.

raulh
November 3rd, 2008, 03:57 PM
bump

TheCPUWizard
November 3rd, 2008, 04:00 PM
Given your attitude:

aww, and i thought you people where smart? holy **** this forum is filled with imbisiles IT'S PARSING A TEXT FILE ON A WEBSERVER U DIPSHIT LEARN TO ****ING CODE before u start talking ****.
obviously you don't know what a auto updater does.http://www.codeguru.com/forum/newreply.php?do=newreply&p=1777704

I would be very suprised if ANYONE answered you.

GremlinSA
November 4th, 2008, 05:59 AM
What you need, to do Hashing (http://en.wikipedia.org/wiki/Hash_table#Choosing_a_good_hash_function)