Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

Using GZipStream compress, I'm getting different results depending on what .NET Framework is compiled to.


Development environment:

Windows 7 Ultimate 64 bits
Visual Studio 2010 Professional

Code:
'**********
Dim buffer As Byte() = Encoding.UTF8.GetBytes("hello")
Dim ms As New MemoryStream()

Using zip As New GZipStream(ms, CompressionMode.Compress, True)
zip.Write(buffer, 0, buffer.Length)
zip.Dispose()
End Using

ms.Position = 0

Dim compressed As Byte() = New Byte(ms.Length - 1) {}

ms.Read(compressed, 0, compressed.Length)
ms.Close()
ms.Dispose()

For Each o As Byte In compressed
Console.WriteLine(o.ToString)
Next
'**********

Results:

Left Column: Compiled for: AnyCPU - Net 4.0
Right Column: Compiled for: AnyCPU - Net 2.0 or Net 3.0 or Net 3.5

31 31
139 139
8 8
0 0
0 0
0 0
0 0
0 0
4 4
0 0
236 237
189 189
7 7
96 96
28 28
73 73
150 150
37 37
38 38
47 47
109 109
202 202
123 123
127 127
74 74
245 245
74 74
215 215
224 224
116 116
161 161
8 8
128 128
96 96
19 19
36 36
216 216
144 144
64 64
16 16
236 236
193 193
136 136
205 205
230 230
146 146
236 236
29 29
105 105
71 71
35 35
41 41
171 171
42 42
129 129
202 202
101 101
86 86
101 101
93 93
102 102
22 22
64 64
204 204
237 237
157 157
188 188
247 247
222 222
123 123
239 239
189 189
247 247
222 222
123 123
239 239
189 189
247 247
186 186
59 59
157 157
78 78
39 39
247 247
223 223
255 255
63 63
92 92
102 102
100 100
1 1
108 108
246 246
206 206
74 74
218 218
201 201
158 158
33 33
128 128
170 170
200 200
31 31
63 63
126 126
124 124
31 31
63 63
34 34
230 230
121 121
89 89
86 86
255 255
79 15
0 134
0 166
0 16
255 54
255 5
134 0
166 0
16 0
54
5
0
0
0


Anyone come across this?

Any comment will be appreciated.

Thank you.
Best Regards from Barcelona.

Josep
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900