@@ -11,71 +11,71 @@ Class WpfCreateZipFileWindow
1111 ' Add any initialization after the InitializeComponent() call.
1212 End Sub
1313
14- Private Sub btnZipIt_Click(sender As Object , e As RoutedEventArgs) Handles btnZipIt.Click
15- Dim sourceDir As String = tbSourceDir.Text.Trim()
14+ Private Sub btnZipIt_Click(sender As Object , e As RoutedEventArgs) Handles btnZipIt.Click
15+ Dim sourceDir As String = tbSourceDir.Text.Trim()
1616
17- ' Simple sanity checks
18- If sourceDir.Length = 0 Then
19- MessageBox.Show( "Please specify a directory" )
20- Return
21- Else
22- If Not Directory.Exists(sourceDir) Then
23- MessageBox.Show(sourceDir, "Directory not found" )
24- Return
25- End If
26- End If
17+ ' Simple sanity checks
18+ If sourceDir.Length = 0 Then
19+ MessageBox.Show( "Please specify a directory" )
20+ Return
21+ Else
22+ If Not Directory.Exists(sourceDir) Then
23+ MessageBox.Show(sourceDir, "Directory not found" )
24+ Return
25+ End If
26+ End If
2727
28- Dim targetName As String = tbZipFileName.Text.Trim()
29- If targetName.Length = 0 Then
30- MessageBox.Show( "No name specified" , "Zip file name error" )
31- Return
32- End If
28+ Dim targetName As String = tbZipFileName.Text.Trim()
29+ If targetName.Length = 0 Then
30+ MessageBox.Show( "No name specified" , "Zip file name error" )
31+ Return
32+ End If
3333
34- Dim astrFileNames() As String = Directory.GetFiles(sourceDir)
35- Dim strmZipOutputStream As ZipOutputStream
34+ Dim astrFileNames() As String = Directory.GetFiles(sourceDir)
35+ Dim strmZipOutputStream As ZipOutputStream
3636
37- strmZipOutputStream = New ZipOutputStream(File.Create(targetName))
37+ strmZipOutputStream = New ZipOutputStream(File.Create(targetName))
3838
39- Try
39+ Try
4040
41- REM Compression Level: 0-9
42- REM 0: no(Compression)
43- REM 9: maximum compression
44- strmZipOutputStream.SetLevel( 5 )
41+ REM Compression Level: 0-9
42+ REM 0: no(Compression)
43+ REM 9: maximum compression
44+ strmZipOutputStream.SetLevel( 5 )
4545
46- Dim strFile As String
47- Dim abyBuffer( 4096 ) As Byte
46+ Dim strFile As String
47+ Dim abyBuffer( 4096 ) As Byte
4848
49- For Each strFile In astrFileNames
50- Dim strmFile As FileStream = File.OpenRead(strFile)
51- Try
49+ For Each strFile In astrFileNames
50+ Dim strmFile As FileStream = File.OpenRead(strFile)
51+ Try
5252
53- Dim objZipEntry As ZipEntry = New ZipEntry(strFile)
53+ Dim objZipEntry As ZipEntry = New ZipEntry(strFile)
5454
55- objZipEntry.DateTime = DateTime.Now
56- objZipEntry.Size = strmFile.Length
55+ objZipEntry.DateTime = DateTime.Now
56+ objZipEntry.Size = strmFile.Length
5757
58- strmZipOutputStream.PutNextEntry(objZipEntry)
59- StreamUtils.Copy(strmFile, strmZipOutputStream, abyBuffer)
60- Finally
61- strmFile.Close()
62- End Try
63- Next
58+ strmZipOutputStream.PutNextEntry(objZipEntry)
59+ StreamUtils.Copy(strmFile, strmZipOutputStream, abyBuffer)
60+ Finally
61+ strmFile.Close()
62+ End Try
63+ Next
6464
65- strmZipOutputStream.Finish()
65+ strmZipOutputStream.Finish()
6666
67- Finally
68- strmZipOutputStream.Close()
69- End Try
67+ Finally
68+ strmZipOutputStream.Close()
69+ End Try
7070
71- MessageBox.Show( "Operation complete" )
72- End Sub
71+ MessageBox.Show( "Operation complete" )
72+ End Sub
7373
74- Private Sub btnBrowseForFolder_Click(sender As Object , e As RoutedEventArgs) Handles btnBrowseForFolder.Click
74+ Private Sub btnBrowseForFolder_Click(sender As Object , e As RoutedEventArgs) Handles btnBrowseForFolder.Click
7575 Dim FolderBrowserDialog As WpfFolderBrowserDialog
7676 FolderBrowserDialog = New WpfFolderBrowserDialog
77- If FolderBrowserDialog.ShowDialog() = True Then
78- tbSourceDir.Text = FolderBrowserDialog.FileName
79- End If
80- End Sub
77+ If FolderBrowserDialog.ShowDialog() = True Then
78+ tbSourceDir.Text = FolderBrowserDialog.FileName
79+ End If
80+ End Sub
8181End Class
0 commit comments