ik heb volgende code om een zip file te maken van mijn bestanden (backup).
hoe kan ik mijn app sluiten als het zippen voltooid is ?
als ik me.close na Zip() zet sluit hij al voor het zippen klaar is .
hoe kan ik mijn app sluiten als het zippen voltooid is ?
als ik me.close na Zip() zet sluit hij al voor het zippen klaar is .
Code:
Private Sub Home_FormClosing(sender As System.Object, e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Try
Dim response_close As MsgBoxResult
response_close = MsgBox("Beheer afsluiten", CType(MsgBoxStyle.Question + MsgBoxStyle.YesNo, MsgBoxStyle), "")
If response_close = MsgBoxResult.Yes Then
If instellingen.sw_backup.Value = True Then
zip()
ElseIf instellingen.sw_backup.Value = False Then
e.Cancel = False
End If
ElseIf response_close = MsgBoxResult.No Then
e.Cancel = True
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Sub zip()
Dim startBuffer() As Byte = {80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
FileIO.FileSystem.WriteAllBytes(instellingen.txt_BackupDestination.Text & "\" & instellingen.txt_backup_name.Text & ".zip", startBuffer, False)
Dim sc As New Shell32.Shell()
Dim input As Shell32.Folder = sc.NameSpace(instellingen.txt_BackupSource.Text)
Dim output As Shell32.Folder = sc.NameSpace(instellingen.txt_BackupDestination.Text & "\" & instellingen.txt_backup_name.Text & ".zip")
output.CopyHere(input.Items, 4)
End Sub