Help! Atualizar Sistema .exe

19/03/2015

0

Bom galera eai blz? fiz uma rotina boa pra baixar atualizações automáticas do sistema e funciona, só que o problema está, que eu subi via FTP um arquivo agora, e tentei manualmente tambem pelo host mais nao deu certo [S7][S7].. ele baixa o .zip e descompacta tudo certo, só que o .exe vem com data de modificação do dia 16/03/2015
sendo que o .zip que eu estou subindo vai com a data de modificação de hoje dia 19/03/2015, só que ele baixa esse 16/03/2015 e só tenho esse arquivo no host ..

Meu host é pago não é gratuito é adquirido pela SmarterAsp.Net, e meu sistema é em VB.Net

Segue abaixo o código fonte do Atualizador que eu fiz.. tirei algumas informações pra ** pq são meus dados e o proxy está correto:

  Imports System.ComponentModel
Imports DevExpress.LookAndFeel
Imports DevExpress.UserSkins
Imports System.Threading
Imports Microsoft.VisualBasic
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Net
Imports System.IO.Compression

Partial Public Class frmUpdate


    Inherits DevExpress.XtraEditors.XtraForm
    Private WithEvents webClient As New Net.WebClient
    Public Event DownloadFileCompleted As AsyncCompletedEventHandler
    Dim handler As AsyncCompletedEventHandler
    <BrowsableAttribute(False)> Public Event Closing As CancelEventHandler
    Dim outputZip As String = "C:\SISTEMA\LabSphere.zip"
    Dim inputZip As String = "C:\SISTEMA\LabSphere.zip"
    Dim inputFolder As String = "C:\SISTEMA"
    Dim outputFolder As String = "C:\SISTEMA"
    Dim shObj As Object = Activator.CreateInstance(Type.GetTypeFromProgID("Shell.Application"))
    Dim Status As Boolean = False

    Shared Sub New()
        DevExpress.UserSkins.BonusSkins.Register()
        DevExpress.Skins.SkinManager.EnableFormSkins()
    End Sub
    Public Sub New()

        InitializeComponent()
    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        DevExpress.Skins.SkinManager.EnableFormSkins()
        UserLookAndFeel.Default.SetSkinStyle("Lilian")

        btnAtualizar.PerformClick()
        SimpleButton1.Enabled = False

    End Sub

    Private Sub Form1_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

        If Status = False Then
            MessageBox.Show("Atenção a Atualização não foi instalada! Favor instalar a atualização", "Aviso Importante", MessageBoxButtons.OK, MessageBoxIcon.Information)
            e.Cancel = True
        Else

        End If

    End Sub

    Private Sub btnAtualizar_Click(sender As Object, e As EventArgs) Handles btnAtualizar.Click

        For Each prog As Process In Process.GetProcesses
            If prog.ProcessName = "LabSphere" Then
                prog.Kill()
            End If
        Next

        If File.Exists("C:\SISTEMA\LabSphere.exe") Then
            File.Delete("C:\SISTEMA\LabSphere.exe")
        End If

        Thread.Sleep(2000)
 
        Dim webClient As New Net.WebClient
        Dim site As String = "http://*****.com.br/Updater/"
        AddHandler webClient.DownloadProgressChanged, AddressOf webClient_ProgressChanged
        AddHandler webClient.DownloadFileCompleted, handler

        Dim Proxy As New Net.WebProxy
        Dim LoginProxy As New Net.NetworkCredential
        With LoginProxy
            .UserName = "logmein"
            .Password = "logmein"
        End With
        With Proxy
            .Address = New Uri("http://10.0.0.1:3128")
            .Credentials = LoginProxy
            .BypassProxyOnLocal = True
        End With

        webClient.Proxy = Proxy

        Dim arq As String, dest As String
        Dim wdown As String
        arq = "LabSphere.zip"
        dest = "C:\Sistema\LabSphere.zip"
        Try
            wdown = site & arq

              webClient.DownloadFileAsync(New System.Uri(wdown), dest)
  
        Catch ex As Exception
            MsgBox(ex.ToString)
   
        End Try


    End Sub


    Private Sub webClient_ProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles webClient.DownloadProgressChanged
        Dim MB_Recebidos As Double, MB_Total As Double

        MB_Recebidos = (e.BytesReceived / 1024 ^ 2)
        MB_Total = (e.TotalBytesToReceive / 1024 ^ 2)

        progDownload.Maximum = e.TotalBytesToReceive
        progDownload.Value = e.BytesReceived
        lblPorcentagem.Text = e.ProgressPercentage & "%"
        lblBytes.Text = Math.Round(MB_Recebidos, 2)
        lblTotal.Text = Math.Round(MB_Total, 2)


        Application.DoEvents()
        If Val(lblBytes.Text) = Val(lblTotal.Text) Then
            lblStatus.Text = "Sistema foi Atualizado com Sucesso"
            SimpleButton1.Enabled = True
        End If
         
    End Sub

    Sub UnZip()

        'Create directory in which you will unzip your items.
        IO.Directory.CreateDirectory(outputFolder)

        'Declare the folder where the items will be extracted.
        Dim output As Object = shObj.NameSpace((outputFolder))

        'Declare the input zip file.
        Dim input As Object = shObj.NameSpace((inputZip))

        'Extract the items from the zip file.
        output.CopyHere((input.Items), 4)

    End Sub
     
 
  
    Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click
        If File.Exists("C:\SISTEMA\LabSphere.exe") Then
            File.Delete("C:\SISTEMA\LabSphere.exe")
        End If

        UnZip()
        Status = True
        MessageBox.Show("A Atualização do Sistema foi instalada com êxito", "Aviso do Sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning)
    End Sub
End Class
 
Lucas Rocha

Lucas Rocha

Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar