Imports System.Windows.Forms
Imports System.IO.Compression
Imports System.IO

Public Class DialogZavarovanje
    Dim izbranPogon
    Dim arhivDat As String = "Kartica"
    Dim arhivCas = System.DateTime.Now.ToString("yyyyMMdd-HHmm")
    Dim mapaZav = My.Application.Info.DirectoryPath.ToString + "\Zavarovanja\"

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        izbranPogon = ComboBox1.Text
        arhivDat = TextBox1.Text
        Dim arhivZav = mapaZav + arhivDat + "_" + arhivCas + ".zip"

        ZipFile.CreateFromDirectory(izbranPogon, arhivZav, CompressionLevel.Optimal, False)

        Me.DialogResult = System.Windows.Forms.DialogResult.OK
        MessageBox.Show("Kartica zavarovana v: " +
arhivZav.ToString)

    End Sub

    Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
        Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub DialogZavarovanje_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        For Each drive In IO.DriveInfo.GetDrives
            'get all removable and fixed drives
            If drive.DriveType = IO.DriveType.Removable And drive.IsReady Then
                'add all found drives into the combobox
                ComboBox1.Items.Add(drive)
            End If
        Next

        TextBox1.Text = arhivDat
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim allDrives() As DriveInfo = DriveInfo.GetDrives()

        Dim d As DriveInfo
        For Each d In allDrives
            If d.Name = ComboBox1.Text Then

                LabelSize.Text = Format(d.TotalSize / 1000 / 1000, "0").ToString + " MB"
                TextBox1.Text = "Kartica_" + d.VolumeLabel.ToString
            End If
        Next

    End Sub
End Class