CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2008
    Posts
    5

    Update function help

    Code:
    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.
    Last edited by raulh; November 3rd, 2008 at 04:57 PM.

  2. #2
    Join Date
    Oct 2008
    Posts
    5

    Re: Update function help

    bump

  3. #3
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Update function help

    Given your attitude:

    Quote Originally Posted by raulh
    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/newrep...eply&p=1777704

    I would be very suprised if ANYONE answered you.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  4. #4
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: Update function help

    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured