Foros del Web » Programación para mayores de 30 ;) » .NET »

Actualizaciones de aplicación

Estas en el tema de Actualizaciones de aplicación en el foro de .NET en Foros del Web. Buenas tardes a todos. Lo que me gusta de onclick es que al arrancar la aplicación ya busca actualizaciones automáticas de la misma y en ...
  #1 (permalink)  
Antiguo 10/01/2009, 05:45
 
Fecha de Ingreso: febrero-2005
Mensajes: 37
Antigüedad: 19 años, 2 meses
Puntos: 0
Actualizaciones de aplicación

Buenas tardes a todos.

Lo que me gusta de onclick es que al arrancar la aplicación ya busca actualizaciones automáticas de la misma y en caso de existir la instala correctamente.
Este tipo de sistema me gustaría añadirlo a mis aplicaciones, pero sin tener que usar onclick.

¿hay algún método?
  #2 (permalink)  
Antiguo 11/01/2009, 10:31
 
Fecha de Ingreso: febrero-2005
Mensajes: 37
Antigüedad: 19 años, 2 meses
Puntos: 0
Respuesta: Actualizaciones de aplicación

Por si a alguien le interesa he encontrado esto:

http://www.codeproject.com/KB/vb/autoupdate.aspx


Código:
Imports System.IO
Imports System.Net

Module Main

    Public Sub Main()
        Dim ExeFile As String ' the program that called the auto update
        Dim RemoteUri As String ' the web location of the files
        Dim Files() As String ' the list of files to be updated
        Dim Key As String ' the key used by the program when called back 
                          ' to know that the program was launched by the 
                          ' Auto Update program
        Dim CommandLine As String ' the command line passed to the original 
                                  ' program if is the case
        Dim myWebClient As New WebClient ' the web client
        Try
            ' Get the parameters sent by the application
            Dim param() As String = Split(Microsoft.VisualBasic.Command(), "|")
            ExeFile = param(0)
            RemoteUri = param(1)
            ' the files to be updated should be separeted by "?"
            Files = Split(param(2), "?") 
            Key = param(3)
            CommandLine = param(4)
        Catch ex As Exception
            ' if the parameters wasn't right just terminate the program
            ' this will happen if the program wasn't called by the system 
            ' to be updated
            Exit Sub
        End Try
        Try
            ' Process each file 
            For i As Integer = 0 To Files.Length - 1
                Try
                    ' try to rename the current file before download the new one
                    ' this is a good procedure since the file can be in use
                    File.Move(Application.StartupPath & "\" & Files(i), _
                        Application.StartupPath & "\" & _
                        Now.TimeOfDay.TotalMilliseconds & ".old")
                Catch ex As Exception
                End Try
                ' download the new version
                myWebClient.DownloadFile(RemoteUri & Files(i), _
                    Application.StartupPath & "\" & Files(i))
            Next
            ' Call back the system with the original command line 
            ' with the key at the end
            System.Diagnostics.Process.Start(ExeFile, CommandLine & Key)
            ' do some clean up -  delete all .old files (if possible) 
            ' in the current directory
            ' if some file stays it will be cleaned next time
            Dim S As String = Dir(Application.StartupPath & "\*.old")
            Do While S <> ""
                Try
                    File.Delete(Application.StartupPath & "\" & S)
                Catch ex As Exception
                End Try
                S = Dir()
            Loop
        Catch ex As Exception
            ' something went wrong... 
            MsgBox("There was a problem runing the Auto Update." & vbCr & _
                "Please Contact [contact info]" & vbCr & ex.Message, _ 
                MsgBoxStyle.Critical)
        End Try
    End Sub
End Module
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:40.