如何在C#中压缩(和解压缩)byte []? [英] How to zip (and unzip) byte[] in C#?

查看:845
本文介绍了如何在C#中压缩(和解压缩)byte []?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#中压缩(和解压缩)字节数组?

How can I zip (and unzip) a byte array in C#?

在少于100个元素的字节数组上使用zip/unzip效率高吗?

Is it efficient to use zip/unzip on byte arrays with less than 100 elements?

推荐答案

DotNetZip 是我使用的库处理.NET中的zip/unzip.如果您不关心格式,而只是在寻找一种压缩技术,则可以研究.Net框架中内置的GZipStream类.这是一个示例..

DotNetZip is the library I have used to handle zip/unzip in .NET . If you don't care about the format and if you are just looking for a compression technique, you could look into GZipStream class that's built into .Net framework. Here's an example. .

基于内容,压缩是高度主观的一件事.您可以对元素进行一些测试以获得平均压缩率,然后可以决定是否值得这样做.

Compression is one thing that's highly subjective based on the content. You could do a few tests with your elements to get get an average compression ratio and then you can decide whether or not it's worth the overhead.

这篇关于如何在C#中压缩(和解压缩)byte []?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆