Tuesday, December 7, 2010

NET System.IO.Compression and zip files

Today i observed an interesting thing in this name space I had a file of 713 kb
When i compressed this file it got a new side of 738KB and when I decompressed this file again it got 712 kb. interestingly file sized increased which I observed on many forum.


some lines from my code. i think i am too old to play with code now

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim sf As System.IO.FileStream = New System.IO.FileStream("c:\test1.doc", FileMode.Open)

Dim ds As System.IO.FileStream = New System.IO.FileStream("C:\test2.doc", FileMode.CreateNew)

Dim Compressedfile As System.IO.Compression.GZipStream = New System.IO.Compression.GZipStream(sf, CompressionMode.Decompress)

'Dim byteData(sf.Length) As Byte

'sf.Read(byteData, 0, sf.Length)

'Compressedfile.Write(byteData, 0, byteData.Length)

'Dim destinationfile(Compressedfile.Length) As Byte

'Compressedfile.Read(destinationfile, 0, destinationfile.Length)

'Dim sw As StreamWriter = New StreamWriter(ds)

'sw.Write(destinationfile, 0, destinationfile.Length)

'ds.Write(destinationfile, 0, destinationfile.Length)


Dim data As Object


data = CType(Compressedfile.ReadByte(), Integer)

If (CType(data, Integer) = -1) Then

Exit Do

End If

ds.WriteByte(CType(data, Byte))

Loop While (CType(data, Integer) <> -1)

End Sub

1 comment:

  1. Zip code database is the most important to searching the any address and country address. So you will use updated database here visit this site than get all zip code list info.