Advertisement
Advertisement
| 03.04.2008 at 08:25AM PST, ID: 23213090 |
|
[x]
Attachment Details
|
||
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: |
Private Sub SimpleZip(ByVal strFileToZip As String, ByVal strZippedFile As String)
Break up the new file location to extract the filename without the path
Dim zipparts() As String = strFileToZip.Split("\"c)
Dim zipfile As String = zipparts(zipparts.Length - 1)
Dim strmZipOutputStream As ZipOutputStream
strmZipOutputStream = New ZipOutputStream(File.Create(strZippedFile))
'strmZipOutputStream.UseZip64 = UseZip64.On
REM Compression Level: 0-9
REM 0: no(Compression)
REM 9: maximum compression
strmZipOutputStream.SetLevel(5)
Dim objZipEntry As ZipEntry = New ZipEntry(Path.GetFileName(strFileToZip))
objZipEntry.DateTime = DateTime.Now
'objZipEntry.Size = strmFile.Length
strmZipOutputStream.PutNextEntry(objZipEntry)
Dim strmFile As FileStream = File.OpenRead(strFileToZip)
Dim abyBuffer(4096) As Byte
Dim sourcebytes As Integer
sourcebytes = strmFile.Read(abyBuffer, 0, abyBuffer.Length)
While sourcebytes > 0
strmZipOutputStream.Write(abyBuffer, 0, sourcebytes)
sourcebytes = strmFile.Read(abyBuffer, 0, abyBuffer.Length)
End While
objZipEntry = Nothing
strmZipOutputStream.CloseEntry()
strmZipOutputStream.Finish()
strmZipOutputStream.Close()
strmZipOutputStream = Nothing
strmFile.Close()
strmFile = Nothing
End Sub
|