Repository navigation
Expand file tree
/
Copy pathMain.vb
More file actions
195 lines (180 loc) · 6.86 KB
/
Copy pathMain.vb
File metadata and controls
195 lines (180 loc) · 6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
Imports System
Imports System.Text
Imports System.Collections
Imports System.IO
Imports System.Windows.Forms
Imports ICSharpCode.SharpZipLib.Zip
Public Class Form1
Inherits System.Windows.Forms.Form
Friend WithEvents btnTest As System.Windows.Forms.Button
Friend Label1 As System.Windows.Forms.Label
Friend chdrSize As System.Windows.Forms.ColumnHeader
Friend chdrName As System.Windows.Forms.ColumnHeader
Friend hdrTime As System.Windows.Forms.ColumnHeader
Friend chdrRawSize As System.Windows.Forms.ColumnHeader
Friend lvZipContents As System.Windows.Forms.ListView
Friend lblListName As System.Windows.Forms.Label
Friend hdrDate As System.Windows.Forms.ColumnHeader
Friend WithEvents btnBrowse As System.Windows.Forms.Button
Friend txtFileName As System.Windows.Forms.TextBox
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Public Shared Sub Main()
Dim fMainForm As New Form1
fMainForm.ShowDialog()
End Sub
Public Sub New()
MyBase.New()
' Must be called for initialization
Me.InitializeComponent()
'
' TODO : Add constructor code after InitializeComponents
'
End Sub
Private Sub InitializeComponent()
Me.txtFileName = New System.Windows.Forms.TextBox
Me.hdrDate = New System.Windows.Forms.ColumnHeader
Me.lblListName = New System.Windows.Forms.Label
Me.lvZipContents = New System.Windows.Forms.ListView
Me.chdrName = New System.Windows.Forms.ColumnHeader
Me.chdrRawSize = New System.Windows.Forms.ColumnHeader
Me.chdrSize = New System.Windows.Forms.ColumnHeader
Me.hdrTime = New System.Windows.Forms.ColumnHeader
Me.Label1 = New System.Windows.Forms.Label
Me.btnTest = New System.Windows.Forms.Button
Me.btnBrowse = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'txtFileName
'
Me.txtFileName.Location = New System.Drawing.Point(117, 21)
Me.txtFileName.Name = "txtFileName"
Me.txtFileName.Size = New System.Drawing.Size(197, 20)
Me.txtFileName.TabIndex = 0
'
'hdrDate
'
Me.hdrDate.Text = "Date"
Me.hdrDate.Width = 71
'
'lblListName
'
Me.lblListName.Location = New System.Drawing.Point(16, 49)
Me.lblListName.Name = "lblListName"
Me.lblListName.Size = New System.Drawing.Size(256, 21)
Me.lblListName.TabIndex = 5
Me.lblListName.Text = "(no file)"
'
'lvZipContents
'
Me.lvZipContents.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.lvZipContents.Columns.AddRange(New System.Windows.Forms.ColumnHeader() {Me.chdrName, Me.chdrRawSize, Me.chdrSize, Me.hdrDate, Me.hdrTime})
Me.lvZipContents.FullRowSelect = True
Me.lvZipContents.GridLines = True
Me.lvZipContents.Location = New System.Drawing.Point(8, 74)
Me.lvZipContents.Name = "lvZipContents"
Me.lvZipContents.Size = New System.Drawing.Size(440, 240)
Me.lvZipContents.Sorting = System.Windows.Forms.SortOrder.Ascending
Me.lvZipContents.TabIndex = 6
Me.lvZipContents.UseCompatibleStateImageBehavior = False
Me.lvZipContents.View = System.Windows.Forms.View.Details
'
'chdrName
'
Me.chdrName.Text = "Name"
Me.chdrName.Width = 127
'
'chdrRawSize
'
Me.chdrRawSize.Text = "RawSize"
Me.chdrRawSize.Width = 67
'
'chdrSize
'
Me.chdrSize.Text = "Size"
Me.chdrSize.Width = 52
'
'hdrTime
'
Me.hdrTime.Text = "Time"
Me.hdrTime.Width = 58
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 21)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(91, 20)
Me.Label1.TabIndex = 3
Me.Label1.Text = "Zip File Name:"
'
'btnTest
'
Me.btnTest.Location = New System.Drawing.Point(352, 24)
Me.btnTest.Name = "btnTest"
Me.btnTest.Size = New System.Drawing.Size(68, 20)
Me.btnTest.TabIndex = 1
Me.btnTest.Text = "View"
'
'btnBrowse
'
Me.btnBrowse.Location = New System.Drawing.Point(320, 21)
Me.btnBrowse.Name = "btnBrowse"
Me.btnBrowse.Size = New System.Drawing.Size(26, 23)
Me.btnBrowse.TabIndex = 7
Me.btnBrowse.Text = "..."
Me.btnBrowse.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(456, 334)
Me.Controls.Add(Me.btnBrowse)
Me.Controls.Add(Me.lvZipContents)
Me.Controls.Add(Me.lblListName)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.txtFileName)
Me.Controls.Add(Me.btnTest)
Me.Name = "Form1"
Me.Text = "Test Zip File"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
Dim objEntry As ZipEntry
Dim dtStamp As DateTime
Dim objItem As ListViewItem
Dim zFile As ZipFile
' Really simple error handling here (catch all)
Try
zFile = New ZipFile(txtFileName.Text)
Catch Ex As System.Exception
MessageBox.Show(Ex.Message)
Exit Sub
End Try
lblListName.Text = "Listing of : " + zFile.Name.ToString
lvZipContents.BeginUpdate()
lvZipContents.Items.Clear()
For Each objEntry In zFile
objItem = New ListViewItem(objEntry.Name)
dtStamp = objEntry.DateTime
objItem.SubItems.Add(objEntry.Size.ToString)
objItem.SubItems.Add(objEntry.CompressedSize.ToString)
objItem.SubItems.Add(dtStamp.ToString("dd-MM-yy"))
objItem.SubItems.Add(dtStamp.ToString("t"))
objItem.SubItems.Add(objEntry.Name.ToString)
lvZipContents.Items.Add(objItem)
Next
lvZipContents.EndUpdate()
End Sub
Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowse.Click
Dim ofn As New OpenFileDialog()
ofn.InitialDirectory = "c:\"
ofn.Filter = "Zip Files (*.zip)|*.zip|All files (*.*)|*.*"
If (ofn.ShowDialog() = Windows.Forms.DialogResult.OK) Then
txtFileName.Text = ofn.FileName
End If
End Sub
End Class