首选,先要找一个开源的c#压缩组件.
如:icsharpcode.sharpziplib 下载地址:http://www.icsharpcode.net/opensource/sharpziplib/default.aspx 【程序编程相关:Oracle Pro*C/C++游标和存】 【推荐阅读:C#SoapFormatter序列化一例】根据它的帮助你就可以做自己需要的东东了. 【扩展信息:怎样建立最基本的 java 开发环境?】 我在使用这个组件行,遇到了一个问题. 当压缩小文件时没有什么错误,一旦源文件达到150m时,它会让你的机器垮掉.(至少是我的机器) 为什么会这样,因为如果源文件是150m时,你就需要在内存申请一个150m大小的字节数组.好点的机器还没问题,一般的机器可就惨了.如果文件在大的话,好机器也受不了的. 为了解决大文件压缩的问题,可以使用分段压缩的方法.private string createzipfile(string path,int m)
{ try { crc32 crc = new crc32(); icsharpcode.sharpziplib.zip.zipoutputstream zipout=new icsharpcode.sharpziplib.zip.zipoutputstream(system.io.file.create(path+".zip")); system.io.filestream fs=system.io.file.openread(path); long pai=1024*1024*m;//每m兆写一次 long forint=fs.length/pai+1; byte[] buffer=null; zipentry entry = new zipentry(system.io.path.getfilename(path)); ... 下一页