Files
Karodeung/Epole/dialogForm/fExtractZip.vb
2026-01-17 00:56:25 +09:00

64 lines
2.2 KiB
VB.net

Public Class fExtractZip
Dim zip As Ionic.Zip.ZipFile
Public Sub New(filename As String)
InitializeComponent()
If System.IO.File.Exists(filename) = False Then
Me.DialogResult = DialogResult.OK
Me.Close()
Else
Dim ro As New Ionic.Zip.ReadOptions()
ro.Encoding = System.Text.Encoding.Default
zip = Ionic.Zip.ZipFile.Read(filename, ro)
AddHandler zip.ExtractProgress, AddressOf extractevents
End If
Me.Text = "스타일 팩 적용 중 - 기다려 주세요"
Me.DoubleBuffered = True
End Sub
Private Sub fExtractZip_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If zip IsNot Nothing Then
Me.ProgressBar1.Maximum = zip.Count
Dim t As New System.Threading.Thread(AddressOf DoExtract)
t.IsBackground = True
t.Start()
End If
End Sub
Private Sub DoExtract()
Try
zip.ExtractAll(AppDomain.CurrentDomain.BaseDirectory, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently)
Catch ex As Exception
' Error handling can be added here
Finally
Me.Invoke(Sub()
If zip IsNot Nothing Then
zip.Dispose()
zip = Nothing
End If
Me.DialogResult = DialogResult.OK
Me.Close()
End Sub)
End Try
End Sub
Delegate Sub extranhandler(sender As Object, e As Ionic.Zip.ExtractProgressEventArgs)
Sub extractevents(sender As Object, e As Ionic.Zip.ExtractProgressEventArgs)
If Me.InvokeRequired Then
Me.BeginInvoke(New extranhandler(AddressOf extractevents), sender, e)
Else
' Update Filename
If e.CurrentEntry IsNot Nothing Then
lbFileName.Text = e.CurrentEntry.FileName
End If
' Update Progress
If Me.ProgressBar1.Value <> e.EntriesExtracted Then
Me.ProgressBar1.Value = e.EntriesExtracted
End If
End If
End Sub
End Class