Davvero non capisco.....
Ora scarica tutto bene, però quando deve installare, usa le istruzioni nell'else:
Form in cui scarica:
Imports System.Net
Imports System.IO
Public Class Forms
Public WithEvents TCP As New System.Net.WebClient 'come webclient
Dim WithEvents download As New WebClient ' come webclient ( downloader )
Private Sub Form6_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'se la directory C:\mods non esiste
If My.Computer.FileSystem.DirectoryExists("C:\" & "mods\") = False Then
'allora la crea
MkDir("C:\mods")
End If
'imposta testo label5=0%
Label6.Text = "0%"
'se è stato selezionato il pacchetto lite in precedenza
' lo scarica
If Form3.RadioButton1.Checked Then
Label4.Text = "Pacchetto_Lite-1.0.zip"
If My.Computer.FileSystem.FileExists("C:\mods\Pacchetto_Lite-1.0.zip") Then
Label1.Text = "Pacchetto già scaricato!"
MsgBox("Il pacchetto è già stato scaricato!", MsgBoxStyle.Information, "Già Scaricato")
Else
download.DownloadFileAsync(New Uri("http://www.sito.org/Pacchetto_Lite-1.0.zip?dl=1"), "C:\mods\Pacchetto_Lite-1.0.zip")
End If
Else
If Form3.RadioButton2.Checked = True Then
Label4.Text = "Pacchetto_Con_XVM-1.0.zip"
If My.Computer.FileSystem.FileExists("C:\mods\Pacchetto_Con_XVM-1.0.zip") Then
Label1.Text = "Pacchetto già scaricato!"
MsgBox("Il pacchetto è già stato scaricato!", MsgBoxStyle.Information, "Già Scaricato")
Else
download.DownloadFileAsync(New Uri("http://www.sito.org/Pacchetto_Con_XVM-1.0.zip?dl=1"), "C:\mods\Pacchetto_Con_XVM-1.0.zip")
End If
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
download.CancelAsync()
ProgressBar1.Value = "0"
Label5.Text = "0%"
MsgBox("Download annullato!", MsgBoxStyle.Information)
File.Delete("C:\mods\" & Label4.Text)
End Sub
Public Mem1 As String, Mem2 As String
Private Sub download_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles download.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
Label6.Text = e.ProgressPercentage & "%"
Label7.Visible = True
Label8.Visible = True
If e.TotalBytesToReceive > 1073741824 Then
Mem1 = Math.Round((((e.TotalBytesToReceive / 1024) / 1024) / 1024), 2) & " GB"
Else
Mem1 = Math.Round((((e.TotalBytesToReceive / 1024) / 1024)), 2) & " MB"
End If
Label9.Text = Mem1
If e.BytesReceived > 1073741824 Then
Mem2 = Math.Round((((e.BytesReceived / 1024) / 1024) / 1024), 2) & " GB"
Else
Mem2 = Math.Round((((e.BytesReceived / 1024) / 1024)), 2) & " MB"
End If
Label7.Text = Mem2
If Label5.Text = "100%" Then
ProgressBar1.Value = "0"
Label5.Text = "0%"
Label1.Text = "Download completato!"
MsgBox("Download completato !", MsgBoxStyle.Information)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form7.Show()
Me.Hide()
End Sub
End Class
nel form in cui deve installare ( cioè estrarre ):
Imports System.IO
Imports System.IO.Compression
Imports Ionic.Zip
Imports System.Windows.Forms
Public Class Form7
Private Sub Form7_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Form3.RadioButton1.Checked = True Then
Label4.Text = "Pacchetto_Lite.zip"
End If
If Form3.RadioButton2.Checked = True Then
Label4.Text = "Pacchetto_Con_XVM.zip"
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Directory.Exists(Form2.TextBox1.Text & "res_modsDavvero non capisco.....
Ora scarica tutto bene, però quando deve installare, usa le istruzioni nell'else:
Form in cui scarica:
Imports System.Net
Imports System.IO
Public Class Forms
Public WithEvents TCP As New System.Net.WebClient 'come webclient
Dim WithEvents download As New WebClient ' come webclient ( downloader )
Private Sub Form6_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'se la directory C:\mods non esiste
If My.Computer.FileSystem.DirectoryExists("C:\" & "mods\") = False Then
'allora la crea
MkDir("C:\mods")
End If
'imposta testo label5=0%
Label6.Text = "0%"
'se è stato selezionato il pacchetto lite in precedenza
' lo scarica
If Form3.RadioButton1.Checked Then
Label4.Text = "Pacchetto_Lite-1.0.zip"
If My.Computer.FileSystem.FileExists("C:\mods\Pacchetto_Lite-1.0.zip") Then
Label1.Text = "Pacchetto già scaricato!"
MsgBox("Il pacchetto è già stato scaricato!", MsgBoxStyle.Information, "Già Scaricato")
Else
download.DownloadFileAsync(New Uri("http://www.sito.org/Pacchetto_Lite-1.0.zip?dl=1"), "C:\mods\Pacchetto_Lite-1.0.zip")
End If
Else
If Form3.RadioButton2.Checked = True Then
Label4.Text = "Pacchetto_Con_XVM-1.0.zip"
If My.Computer.FileSystem.FileExists("C:\mods\Pacchetto_Con_XVM-1.0.zip") Then
Label1.Text = "Pacchetto già scaricato!"
MsgBox("Il pacchetto è già stato scaricato!", MsgBoxStyle.Information, "Già Scaricato")
Else
download.DownloadFileAsync(New Uri("http://www.sito.org/Pacchetto_Con_XVM-1.0.zip?dl=1"), "C:\mods\Pacchetto_Con_XVM-1.0.zip")
End If
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
download.CancelAsync()
ProgressBar1.Value = "0"
Label5.Text = "0%"
MsgBox("Download annullato!", MsgBoxStyle.Information)
File.Delete("C:\mods\" & Label4.Text)
End Sub
Public Mem1 As String, Mem2 As String
Private Sub download_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles download.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
Label6.Text = e.ProgressPercentage & "%"
Label7.Visible = True
Label8.Visible = True
If e.TotalBytesToReceive > 1073741824 Then
Mem1 = Math.Round((((e.TotalBytesToReceive / 1024) / 1024) / 1024), 2) & " GB"
Else
Mem1 = Math.Round((((e.TotalBytesToReceive / 1024) / 1024)), 2) & " MB"
End If
Label9.Text = Mem1
If e.BytesReceived > 1073741824 Then
Mem2 = Math.Round((((e.BytesReceived / 1024) / 1024) / 1024), 2) & " GB"
Else
Mem2 = Math.Round((((e.BytesReceived / 1024) / 1024)), 2) & " MB"
End If
Label7.Text = Mem2
If Label5.Text = "100%" Then
ProgressBar1.Value = "0"
Label5.Text = "0%"
Label1.Text = "Download completato!"
MsgBox("Download completato !", MsgBoxStyle.Information)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form7.Show()
Me.Hide()
End Sub
End Class
nel form in cui deve installare ( cioè estrarre ):
Imports System.IO
Imports System.IO.Compression
Imports Ionic.Zip
Imports System.Windows.Forms
Public Class Form7
Private Sub Form7_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Form3.RadioButton1.Checked = True Then
Label4.Text = "Pacchetto_Lite.zip"
End If
If Form3.RadioButton2.Checked = True Then
Label4.Text = "Pacchetto_Con_XVM.zip"
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Directory.Exists(Form2.TextBox1.Text & "res_mods{parsed_message}.8.9") Then
Directory.Delete(Form2.TextBox1.Text & "res_mods{parsed_message}.8.9", True)
End If
If Directory.Exists(Form2.TextBox1.Text & "res_mods\xvm") Then
Directory.Delete(Form2.TextBox1.Text & "res_mods\xvm", True)
End If
If Label4.Text = "Pacchetto_Lite.zip" Then
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "Installazione Completata" ' Define message.
style = MsgBoxStyle.Information
title = "MOD" ' Define title.
Dim ZipToUnpack As String = "C:\mods\Pacchetto_Lite-1.0.zip"
Dim TargetDir As String = Form2.TextBox1.Text
Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
Dim ea As ZipEntry
Me.ProgressBar1.Maximum = zip1.Entries.Count
' here, we extract every entry, but we could extract
' based on entry name, size, date, etc.
For Each ea In zip1
ea.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
Me.ProgressBar1.PerformStep()
Next
End Using
' Display message.
response = MsgBox(msg, style, title)
Button3.Visible = False
Button1.Visible = True
Label1.Text = "Installazione completata !"
Else
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "Installazione Completata" ' Define message.
style = MsgBoxStyle.Information
title = "MOD" ' Define title.
Dim ZipToUnpack As String = "C:\mods\Pacchetto_Con_XVM-1.0.zip"
Dim TargetDir As String = Form2.TextBox1.Text
Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
Dim ea As ZipEntry
Me.ProgressBar1.Maximum = zip1.Entries.Count
' here, we extract every entry, but we could extract
' based on entry name, size, date, etc.
For Each ea In zip1
ea.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
Me.ProgressBar1.PerformStep()
Next
End Using
' Display message.
response = MsgBox(msg, style, title)
Button3.Visible = False
Button1.Visible = True
Label1.Text = "Installazione completata !"
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim msg As String = "Rimuovere i file scaricati ?" 'Definisce la variabile titolo come il titolo del msgbox
Dim stile As MsgBoxStyle = MsgBoxStyle.YesNo 'Definsce la variabile stile com stile del msgbox
Dim titolo As String = "Pulizia" 'Definisce la variabile titolo del msgbox
Dim risposta As MsgBoxResult 'Definisce il risultato del msgbox
risposta = MsgBox(msg, stile, titolo)
If risposta = MsgBoxResult.Yes Then 'Se l'utente seleziona si.
Directory.Delete("C:\mods")
MsgBox("Pulizia completata!", MsgBoxStyle.Information, "Pulizia!")
Else
' Perform some other action.
End If
Form8.Show()
Me.Close()
End Sub
Public Sub SvuotaDir(ByVal directory As String)
Dim di As IO.DirectoryInfo = New IO.DirectoryInfo(directory)
For Each File As IO.FileInfo In di.GetFiles()
File.Delete()
Next
End Sub
End Class
.8.9") Then
Directory.Delete(Form2.TextBox1.Text & "res_modsDavvero non capisco.....
Ora scarica tutto bene, però quando deve installare, usa le istruzioni nell'else:
Form in cui scarica:
Imports System.Net
Imports System.IO
Public Class Forms
Public WithEvents TCP As New System.Net.WebClient 'come webclient
Dim WithEvents download As New WebClient ' come webclient ( downloader )
Private Sub Form6_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'se la directory C:\mods non esiste
If My.Computer.FileSystem.DirectoryExists("C:\" & "mods\") = False Then
'allora la crea
MkDir("C:\mods")
End If
'imposta testo label5=0%
Label6.Text = "0%"
'se è stato selezionato il pacchetto lite in precedenza
' lo scarica
If Form3.RadioButton1.Checked Then
Label4.Text = "Pacchetto_Lite-1.0.zip"
If My.Computer.FileSystem.FileExists("C:\mods\Pacchetto_Lite-1.0.zip") Then
Label1.Text = "Pacchetto già scaricato!"
MsgBox("Il pacchetto è già stato scaricato!", MsgBoxStyle.Information, "Già Scaricato")
Else
download.DownloadFileAsync(New Uri("http://www.sito.org/Pacchetto_Lite-1.0.zip?dl=1"), "C:\mods\Pacchetto_Lite-1.0.zip")
End If
Else
If Form3.RadioButton2.Checked = True Then
Label4.Text = "Pacchetto_Con_XVM-1.0.zip"
If My.Computer.FileSystem.FileExists("C:\mods\Pacchetto_Con_XVM-1.0.zip") Then
Label1.Text = "Pacchetto già scaricato!"
MsgBox("Il pacchetto è già stato scaricato!", MsgBoxStyle.Information, "Già Scaricato")
Else
download.DownloadFileAsync(New Uri("http://www.sito.org/Pacchetto_Con_XVM-1.0.zip?dl=1"), "C:\mods\Pacchetto_Con_XVM-1.0.zip")
End If
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
download.CancelAsync()
ProgressBar1.Value = "0"
Label5.Text = "0%"
MsgBox("Download annullato!", MsgBoxStyle.Information)
File.Delete("C:\mods\" & Label4.Text)
End Sub
Public Mem1 As String, Mem2 As String
Private Sub download_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles download.DownloadProgressChanged
ProgressBar1.Value = e.ProgressPercentage
Label6.Text = e.ProgressPercentage & "%"
Label7.Visible = True
Label8.Visible = True
If e.TotalBytesToReceive > 1073741824 Then
Mem1 = Math.Round((((e.TotalBytesToReceive / 1024) / 1024) / 1024), 2) & " GB"
Else
Mem1 = Math.Round((((e.TotalBytesToReceive / 1024) / 1024)), 2) & " MB"
End If
Label9.Text = Mem1
If e.BytesReceived > 1073741824 Then
Mem2 = Math.Round((((e.BytesReceived / 1024) / 1024) / 1024), 2) & " GB"
Else
Mem2 = Math.Round((((e.BytesReceived / 1024) / 1024)), 2) & " MB"
End If
Label7.Text = Mem2
If Label5.Text = "100%" Then
ProgressBar1.Value = "0"
Label5.Text = "0%"
Label1.Text = "Download completato!"
MsgBox("Download completato !", MsgBoxStyle.Information)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form7.Show()
Me.Hide()
End Sub
End Class
nel form in cui deve installare ( cioè estrarre ):
Imports System.IO
Imports System.IO.Compression
Imports Ionic.Zip
Imports System.Windows.Forms
Public Class Form7
Private Sub Form7_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Form3.RadioButton1.Checked = True Then
Label4.Text = "Pacchetto_Lite.zip"
End If
If Form3.RadioButton2.Checked = True Then
Label4.Text = "Pacchetto_Con_XVM.zip"
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Directory.Exists(Form2.TextBox1.Text & "res_mods{parsed_message}.8.9") Then
Directory.Delete(Form2.TextBox1.Text & "res_mods{parsed_message}.8.9", True)
End If
If Directory.Exists(Form2.TextBox1.Text & "res_mods\xvm") Then
Directory.Delete(Form2.TextBox1.Text & "res_mods\xvm", True)
End If
If Label4.Text = "Pacchetto_Lite.zip" Then
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "Installazione Completata" ' Define message.
style = MsgBoxStyle.Information
title = "MOD" ' Define title.
Dim ZipToUnpack As String = "C:\mods\Pacchetto_Lite-1.0.zip"
Dim TargetDir As String = Form2.TextBox1.Text
Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
Dim ea As ZipEntry
Me.ProgressBar1.Maximum = zip1.Entries.Count
' here, we extract every entry, but we could extract
' based on entry name, size, date, etc.
For Each ea In zip1
ea.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
Me.ProgressBar1.PerformStep()
Next
End Using
' Display message.
response = MsgBox(msg, style, title)
Button3.Visible = False
Button1.Visible = True
Label1.Text = "Installazione completata !"
Else
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "Installazione Completata" ' Define message.
style = MsgBoxStyle.Information
title = "MOD" ' Define title.
Dim ZipToUnpack As String = "C:\mods\Pacchetto_Con_XVM-1.0.zip"
Dim TargetDir As String = Form2.TextBox1.Text
Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
Dim ea As ZipEntry
Me.ProgressBar1.Maximum = zip1.Entries.Count
' here, we extract every entry, but we could extract
' based on entry name, size, date, etc.
For Each ea In zip1
ea.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
Me.ProgressBar1.PerformStep()
Next
End Using
' Display message.
response = MsgBox(msg, style, title)
Button3.Visible = False
Button1.Visible = True
Label1.Text = "Installazione completata !"
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim msg As String = "Rimuovere i file scaricati ?" 'Definisce la variabile titolo come il titolo del msgbox
Dim stile As MsgBoxStyle = MsgBoxStyle.YesNo 'Definsce la variabile stile com stile del msgbox
Dim titolo As String = "Pulizia" 'Definisce la variabile titolo del msgbox
Dim risposta As MsgBoxResult 'Definisce il risultato del msgbox
risposta = MsgBox(msg, stile, titolo)
If risposta = MsgBoxResult.Yes Then 'Se l'utente seleziona si.
Directory.Delete("C:\mods")
MsgBox("Pulizia completata!", MsgBoxStyle.Information, "Pulizia!")
Else
' Perform some other action.
End If
Form8.Show()
Me.Close()
End Sub
Public Sub SvuotaDir(ByVal directory As String)
Dim di As IO.DirectoryInfo = New IO.DirectoryInfo(directory)
For Each File As IO.FileInfo In di.GetFiles()
File.Delete()
Next
End Sub
End Class
.8.9", True)
End If
If Directory.Exists(Form2.TextBox1.Text & "res_mods\xvm") Then
Directory.Delete(Form2.TextBox1.Text & "res_mods\xvm", True)
End If
If Label4.Text = "Pacchetto_Lite.zip" Then
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "Installazione Completata" ' Define message.
style = MsgBoxStyle.Information
title = "MOD" ' Define title.
Dim ZipToUnpack As String = "C:\mods\Pacchetto_Lite-1.0.zip"
Dim TargetDir As String = Form2.TextBox1.Text
Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
Dim ea As ZipEntry
Me.ProgressBar1.Maximum = zip1.Entries.Count
' here, we extract every entry, but we could extract
' based on entry name, size, date, etc.
For Each ea In zip1
ea.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
Me.ProgressBar1.PerformStep()
Next
End Using
' Display message.
response = MsgBox(msg, style, title)
Button3.Visible = False
Button1.Visible = True
Label1.Text = "Installazione completata !"
Else
Dim msg As String
Dim title As String
Dim style As MsgBoxStyle
Dim response As MsgBoxResult
msg = "Installazione Completata" ' Define message.
style = MsgBoxStyle.Information
title = "MOD" ' Define title.
Dim ZipToUnpack As String = "C:\mods\Pacchetto_Con_XVM-1.0.zip"
Dim TargetDir As String = Form2.TextBox1.Text
Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
Dim ea As ZipEntry
Me.ProgressBar1.Maximum = zip1.Entries.Count
' here, we extract every entry, but we could extract
' based on entry name, size, date, etc.
For Each ea In zip1
ea.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
Me.ProgressBar1.PerformStep()
Next
End Using
' Display message.
response = MsgBox(msg, style, title)
Button3.Visible = False
Button1.Visible = True
Label1.Text = "Installazione completata !"
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim msg As String = "Rimuovere i file scaricati ?" 'Definisce la variabile titolo come il titolo del msgbox
Dim stile As MsgBoxStyle = MsgBoxStyle.YesNo 'Definsce la variabile stile com stile del msgbox
Dim titolo As String = "Pulizia" 'Definisce la variabile titolo del msgbox
Dim risposta As MsgBoxResult 'Definisce il risultato del msgbox
risposta = MsgBox(msg, stile, titolo)
If risposta = MsgBoxResult.Yes Then 'Se l'utente seleziona si.
Directory.Delete("C:\mods")
MsgBox("Pulizia completata!", MsgBoxStyle.Information, "Pulizia!")
Else
' Perform some other action.
End If
Form8.Show()
Me.Close()
End Sub
Public Sub SvuotaDir(ByVal directory As String)
Dim di As IO.DirectoryInfo = New IO.DirectoryInfo(directory)
For Each File As IO.FileInfo In di.GetFiles()
File.Delete()
Next
End Sub
End Class