G
Guest
The compression part of this code works fine for me, but the decompression
part of this code does not. The output file from that is the same as the
compressed file.
What is wrong with my code?
Thanks,
Jon
'compression starts here
Dim src As FileStream = File.OpenRead(Fn)
Dim dst As FileStream = File.Create(Ofn)
Dim cmp As New DeflateStream(dst, CompressionMode.Compress)
Dim ba(src.Length) As Byte
src.Read(ba, 0, src.Length)
cmp.Write(ba, 0, src.Length)
cmp.Close()
src.Close()
dst.Close()
'decompression starts here
src = File.OpenRead(Ofn)
Dim slen As Integer = src.Length
Dim ba1(slen * 2) As Byte
cmp = New DeflateStream(src, CompressionMode.Decompress)
cmp.Read(ba1, 0, slen)
dst = File.Create(txt)
dst.Write(ba1, 0, slen)
cmp.Close()
src.Close()
dst.Close()
part of this code does not. The output file from that is the same as the
compressed file.
What is wrong with my code?
Thanks,
Jon
'compression starts here
Dim src As FileStream = File.OpenRead(Fn)
Dim dst As FileStream = File.Create(Ofn)
Dim cmp As New DeflateStream(dst, CompressionMode.Compress)
Dim ba(src.Length) As Byte
src.Read(ba, 0, src.Length)
cmp.Write(ba, 0, src.Length)
cmp.Close()
src.Close()
dst.Close()
'decompression starts here
src = File.OpenRead(Ofn)
Dim slen As Integer = src.Length
Dim ba1(slen * 2) As Byte
cmp = New DeflateStream(src, CompressionMode.Decompress)
cmp.Read(ba1, 0, slen)
dst = File.Create(txt)
dst.Write(ba1, 0, slen)
cmp.Close()
src.Close()
dst.Close()