Making a .zip creator and extractor

Posts 1–7 of 7 · Page 1 of 1
Making a .zip creator and extractor
hey guys i need help making a program that can create .zip archives and extract files from .zip archives. i already have the reference ICSharpCode.SharpZipLib but i dont know what codes to use. any help?

thanks.
Spoonfeedin..

[highlight="VB.Net"]Sub CreateZip(ByVal FileToPack As String, ByVal WhereToSave As String, Optional ByVal Password As String = "", Optional ByVal compression As Integer = 5)

Dim stream As New ZipOutputStream(File.Create(Path.Combine(WhereToSa ve, Path.GetFileName(FileToPack) & ".zip")))

stream.Password = Password

stream.SetLevel(compression)

Dim entry As New ZipEntry(Path.GetFileName(FileToPack))

entry.DateTime = DateTime.Now

Using fs As FileStream = File.OpenRead(FileToPack)
Dim buffer As Byte() = New Byte(fs.Length - 1) {}
fs.Read(buffer, 0, buffer.Length)
entry.Size = fs.Length
fs.Close()
stream.PutNextEntry(entry)
stream.Write(buffer, 0, buffer.Length)
End Using
stream.Finish()
stream.Close()
End Sub


Sub ExtractZip(ByVal FileToUnzip As String, ByVal WhereToSave As String, Optional ByVal Password As String = "")
Dim fz As New FastZip
fz.Password = Password
fz.ExtractZip(FileToUnzip, WhereToSave, "")
End Sub[/highlight]
Quote Originally Posted by Blubb1337 View Post
Spoonfeedin..

[highlight="VB.Net"]Sub CreateZip(ByVal FileToPack As String, ByVal WhereToSave As String, Optional ByVal Password As String = "", Optional ByVal compression As Integer = 5)

Dim stream As New ZipOutputStream(File.Create(Path.Combine(WhereToSa ve, Path.GetFileName(FileToPack) & ".zip")))

stream.Password = Password

stream.SetLevel(compression)

Dim entry As New ZipEntry(Path.GetFileName(FileToPack))

entry.DateTime = DateTime.Now

Using fs As FileStream = File.OpenRead(FileToPack)
Dim buffer As Byte() = New Byte(fs.Length - 1) {}
fs.Read(buffer, 0, buffer.Length)
entry.Size = fs.Length
fs.Close()
stream.PutNextEntry(entry)
stream.Write(buffer, 0, buffer.Length)
End Using
stream.Finish()
stream.Close()
End Sub


Sub ExtractZip(ByVal FileToUnzip As String, ByVal WhereToSave As String, Optional ByVal Password As String = "")
Dim fz As New FastZip
fz.Password = Password
fz.ExtractZip(FileToUnzip, WhereToSave, "")
End Sub[/highlight]
dang that was fast. what codes would i put in the textboxes? like where they would save the file? or where they would extract the files to?
Openfiledialog/Savefiledialog.

I'm off 2 sleep.
Quote Originally Posted by Blubb1337 View Post
Openfiledialog/Savefiledialog.

I'm off 2 sleep.
urm ok... i know the file dialogs put do i edit the above code to refrence to the textboxes?
Quote Originally Posted by Accelerate' View Post
urm ok... i know the file dialogs put do i edit the above code to refrence to the textboxes?
CreateZip(TextBox1.Text .. etc)
Quote Originally Posted by NOOB View Post


CreateZip(TextBox1.Text .. etc)
thankz i think i figured out the other parts
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us