- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 DeflateStream 在我的机器上压缩短字符串
public byte[] Compress(byte[] oryginalBytes)
{
using (var msi = new MemoryStream(oryginalBytes))
using (var mso = new MemoryStream())
{
using (var gs = new DeflateStream(mso, CompressionMode.Compress))
{
msi.CopyTo(gs);
}
return mso.ToArray();
}
}
然后运行这段代码:
Compress(Encoding.Unicode.GetBytes("[TEST]"));
在我的机器上(windows 7 64 位)我得到了 12 个元素的字节数组:
139 102 8 97 112 101 8 6 146 177 12 0
然后在我的构建服务器(Windows 2008 64 位)上运行它,我有 120 个元素的字节数组。
236 189 7 96 28 73 150 37 38 47 109 202 123 127 74 245 74 215 224 116 161 8 128 96 19 36 216 144 64 16 236 193 136 205 230 146 236 29 105 71 35 41 171 42 129 202 101 86 101 93 102 22 64 204 237 157 188 247 222 123 239 189 247 222 123 239 189 247 186 59 157 78 39 247 223 255 63 92 102 100 1 108 246 206 74 218 201 158 33 128 170 200 31 63 126 124 31 63 34 190 247 107 188 249 53 78 127 141 215 244 239 247 127 141 255 39 0 0 255 255
有人知道为什么这个行为如此奇怪吗?
最佳答案
This class represents the Deflate algorithm, which is an industry-standard algorithm for lossless file compression and decompression. Starting with the .NET Framework 4.5, the DeflateStream class uses the zlib library. As a result, it provides a better compression algorithm and, in most cases, a smaller compressed file than it provides in earlier versions of the .NET Framework.
关于c# - 为什么我在不同的机器上使用 DeflateStream 有不同的压缩字节数组大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19162712/
我正在研究 my other question 的解决方案它正在读取 PNG 的“zTXt” block 中的数据。我就在文件中定位 block ,并阅读 zTXt 的关键字。我无法读取 zTXt 的
我试图使用 DeflateStream 压缩字节数组。拧完数据后,我正在寻找一种关闭压缩的方法(标记为完成)。起初,我尝试了 Dispose(),然后是 Close(),但这些都使结果 MemoryS
我有以下代码: MemoryStream resultStream = new MemoryStream(); string users = ""//Really long string goes h
我正在使用 DeflateStream 在我的机器上压缩短字符串 public byte[] Compress(byte[] oryginalBytes) { using (var msi =
尝试压缩和解压缩 MemoryStream 但似乎 CopyTo 没有像预期的那样工作?为什么?如何解决这个问题? public static MemoryStream Compress(Memory
zlib 的 deflate 函数接受一个 Z_FULL_FLUSH 选项作为它的参数,据我所知,当执行 full flush 时,一个 full flush point (0,0,0xFF,0xFF
我正在尝试对对象进行自定义序列化/反序列化,以及使用 DeflateStreams 压缩/解压缩序列化数据。我最初是为更复杂的对象这样做的,但将其缩减以尝试找出问题所在,但它变得更加令人费解,因为它仍
我在使用 C# .NET DeflateStream(..., CompressionMode.Decompress) 读取压缩(压缩)数据文件时遇到问题。该文件是早些时候使用 DeflateStre
所以这是一个奇怪的。我有这个方法来获取 Base64 编码的压缩字符串并返回原始数据: public static string Base64Decompress(string base64data)
在 Java 中,这按预期工作: public static void testwrite(String filename) throws IOException { FileOutput
我目前正在尝试将一些涉及使用 DeflateStream 的 C# 代码移植到没有 .NET 框架支持的标准 C++ 中。这种功能的一个例子是: public static byte[] ReadCo
我用 DeflateStream 压缩了数据。我可以解压 whit c#,但我如何解压 whit c++ (VS2013 RC)?我试过给 zlib 充气。没用。 最佳答案 有一些 header 和校
我使用 DeflateStream 实现了 Websocket 压缩,如下所示: public byte[] Compress(Stream input) { usin
我不熟悉 DeflateStream 的内部结构,但我需要将文件存储在供应商的数据库系统中,该系统在二进制附件上使用 DeflateStream。我注意到的第一件事是我的所有文件在压缩后都变大了 10
我正在尝试在 C# 中使用 deflate/gzip 流,但压缩后的文件似乎比以前大。 例如,我压缩了一个 900ko 的 docx 文件,但它产生了一个 1.4Mo 的文件! 它对我尝试过的每个文件
我需要一种在 .net 中压缩图像的方法,所以我研究了使用 .net GZipStream 类(或 DeflateStream)。但是我发现解压缩并不总是成功,有时图像可以很好地解压缩,有时我会收到
MSDN 文档告诉我以下内容: The GZipStream class uses the gzip data format, which includes a cyclic redundancy c
我不是格式方面的专家,但我猜测由于格式化开销,压缩数据的某些输入数据实际上可能更长。 我对此没有意见,但我不满意的是 GZipStream/DeflateStream.Write() 的计数参数的记录
我需要 Windows 和 Ubuntu 之间的跨平台压缩/解压缩。据我了解,从 .NET 4.5 开始,DeflateStream 类使用 zlib 作为压缩库。我编写了两个小测试程序来压缩数据,一
我正在使用单声道来膨胀/收缩字节。这是代码: public static byte[] Inflate(byte[] data) { using (MemoryStream i
我是一名优秀的程序员,十分优秀!