G
Grok
Trying to zip/unzip files from VB.NET 2005 with 2.0 .NET Framework ...
but the file created "SampleFile.zip" is not a readable zip file.
(Using GZipStream works correctly to produce a readable .gz file)
How do I properly create a .zip file without 3rd-party lib?
Dim sourceFile As FileStream =
File.OpenRead("c:\temp\SampleFile.chm")
Dim destFile As FileStream =
File.Create("c:\temp\SampleFile.zip")
'wrap dest stream with compression stream
Dim compStream As New DeflateStream(destFile,
CompressionMode.Compress)
'copy data from source stream to destination stream
Dim theByte As Integer = sourceFile.ReadByte()
While theByte <> -1
compStream.WriteByte(CType(theByte, Byte))
theByte = sourceFile.ReadByte()
End While
compStream.Flush()
'clean up
sourceFile.Close()
compStream.Close()
destFile.Close()
but the file created "SampleFile.zip" is not a readable zip file.
(Using GZipStream works correctly to produce a readable .gz file)
How do I properly create a .zip file without 3rd-party lib?
Dim sourceFile As FileStream =
File.OpenRead("c:\temp\SampleFile.chm")
Dim destFile As FileStream =
File.Create("c:\temp\SampleFile.zip")
'wrap dest stream with compression stream
Dim compStream As New DeflateStream(destFile,
CompressionMode.Compress)
'copy data from source stream to destination stream
Dim theByte As Integer = sourceFile.ReadByte()
While theByte <> -1
compStream.WriteByte(CType(theByte, Byte))
theByte = sourceFile.ReadByte()
End While
compStream.Flush()
'clean up
sourceFile.Close()
compStream.Close()
destFile.Close()