Inquiridor
Descompactar e subistituir arquivo

Pergunta
-
Blz Galera! estou tentando updater e queria saber como faço para extrair o arquivo rar que o programa baixar e susbtituir caso os arquivos do winrar ja exista no programa ?
desde ja agradeço a atencao de todos(sou novato na area de vb)
aki o meu codigo
Imports System.Net Public Class Form1 WithEvents WebClient1 As New WebClient Public LAUNCHER As String = Application.StartupPath.Replace("\", "/") & "/" Public Sub Atualizar() If System.IO.File.Exists(Application.StartupPath & "\update.rar") Then System.IO.File.Delete(Application.StartupPath & "\update.rar") End If WebClient1.DownloadFileAsync(New Uri("http://127.0.0.1/update.rar"), Application.StartupPath & "\update.rar") AddHandler WebClient1.DownloadProgressChanged, AddressOf Me.DownloadProgressChangedCallback AddHandler WebClient1.DownloadFileCompleted, AddressOf Me.DownloadFileCompletedCallback End Sub Private Sub DownloadProgressChangedCallback(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) ' Atualiza ProgressBar ProgressBar1.Value = e.ProgressPercentage End Sub Private Sub DownloadFileCompletedCallback(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) ' Remove eventos RemoveHandler WebClient1.DownloadProgressChanged, AddressOf Me.DownloadProgressChangedCallback RemoveHandler WebClient1.DownloadFileCompleted, AddressOf Me.DownloadFileCompletedCallback End Sub Public Function GetSettingItem(ByVal File As String, ByVal Identifier As String) As String Dim S As New IO.StreamReader(File) : Dim Result As String = "" Do While (S.Peek <> -1) Dim Line As String = S.ReadLine If Line.ToLower.StartsWith(Identifier.ToLower & ":") Then Result = Line.Substring(Identifier.Length + 2) End If Loop Return Result End Function Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If ProgressBar1.Value < 100 Then MsgBox("ESPERA COMPLETAR O UPDATE") Return End If Dim DX9 As String = GetSettingItem("config.txt", "DX9") Dim OPENGL As String = GetSettingItem("config.txt", "OPENGL") Dim Classic As String = GetSettingItem("config.txt", "CLASSIC") If CheckBox1.Checked = True Then System.Diagnostics.Process.Start(OPENGL) ElseIf CheckBox2.Checked = True Then System.Diagnostics.Process.Start(DX9) ElseIf CheckBox3.Checked = True Then System.Diagnostics.Process.Start(Classic) Else MsgBox("Escolhe seu Client") End If End Sub Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged If CheckBox2.Checked = True Then CheckBox2.Checked = False End If If CheckBox3.Checked = True Then CheckBox3.Checked = False End If End Sub Private Sub CheckBox2_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox2.CheckedChanged If CheckBox1.Checked = True Then CheckBox1.Checked = False End If If CheckBox3.Checked = True Then CheckBox3.Checked = False End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click PictureBox1.Image = Image.FromFile("launcher\novidades.png") End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click PictureBox1.Image = Image.FromFile("launcher\dicas.png") End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim VersaoSite As String = WebClient1.DownloadString("http://127.0.0.1/versao.txt") Dim VersaoAtual As String = GetSettingItem("config.txt", "VERSAO") If VersaoSite > VersaoAtual Then Atualizar() End If End Sub Private Sub CheckBox3_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox3.CheckedChanged If CheckBox1.Checked = True Then CheckBox1.Checked = False End If If CheckBox2.Checked = True Then CheckBox2.Checked = False End If End Sub End Class
Todas as Respostas
-
Boa tarde Aberos,
Da uma olhada nisso, acho que vai te ajudar:
http://msdn.microsoft.com/pt-br/library/ms404280(v=vs.110).aspx
http://social.msdn.microsoft.com/Forums/pt-BR/baa4bb11-deb6-450d-9e11-fe9b5b2772ae/compactar-descompactar-arquivos-via-c?forum=vscsharppt
Att,
Ricardo Cortes Microsoft Contingent Staff
Esse contedo e fornecido sem garantias de qualquer tipo, seja expressa ou implicita.
MSDN Community Support
-