资源简介
最简单的7Z SDK用法 DEMO
API:
Zip(Stream inStream, Stream outStream)
Unzip(Stream inStream, Stream outStream)
包括全部源代码, visual studio 2010, 打开就可以用!100%
这是我测试的结果:
Input length 100000
Output length 268
Ziped rate 0.268%
Input length 268
Output length 100000
UnZiped rate 37313.4328358209%
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using SevenZip;
namespace Demo7zApi
{
class Program
{
public static void Zip(Stream inStream Stream outStream)
{
bool dictionaryIsDefined = false;
Int32 dictionary = 1 << 21;
if (!dictionaryIsDefined)
dictionary = 1 << 23;
Int32 posStateBits = 2;
Int32 litContextBits = 3; // for normal files
// UInt32 litContextBits = 0; // for 32-bit data
Int32 litPosBits = 0;
// UInt32 litPosBits = 2; // for 32-bit data
Int32 algorithm = 2;
Int32 numFastBytes = 128;
string mf = “bt4“;
bool eos = false;
CoderPropID[] propIDs =
{
CoderPropID.DictionarySize
CoderPropID.PosStateBits
CoderPropID.LitContextBits
CoderPropID.LitPosBits
CoderPropID.Algorithm
CoderPropID.NumFastBytes
CoderPropID.MatchFinder
CoderPropID.EndMarker
};
object[] properties =
{
(Int32)(dictionary)
(Int32)(posStateBits)
(Int32)(litContextBits)
(Int32)(litPosBits)
(Int32)(algorithm)
(Int32)(numFastBytes)
mf
eos
};
SevenZip.Compression.LZMA.Encoder encoder = new SevenZip.Compression.LZMA.Encoder();
encoder.SetCoderProperties(propIDs properties);
encoder.WriteCoderProperties(outStream);
Int64 fileSize;
fileSize = inStream.Length;
for (int i = 0; i < 8; i++)
outStream.WriteByte((Byte)(fileSize >> (8 * i)));
encoder.Code(inStream outStream -1 -1 null);
}
public static void Unzip(Stream inStream Stream outStream)
{
byte[] properties = new byte[5];
if (inStream.Read(properties 0 5) != 5)
throw (new Exception(“input .lzma is too short“));
SevenZip.Compression.LZMA.Decoder decoder = new SevenZip.Compression.LZMA.Decoder();
decoder.SetDecoderProperties(properties);
long outSize = 0;
for (int i = 0; i < 8; i++)
{
int v = inStream.ReadByte();
if (v < 0)
throw (new Exception(“Can‘t Read 1“));
outSize |= ((long)(byte)v) << (8 * i);
}
long compressedSize = inStream.Length - inStream.Position;
decoder.Code(inStream outStream compressedSize outSize null);
}
static int Main(string[] args)
{
try
{
byte[] bytes = new byte[100000];
for (byte i = 0; i < 100; i++)
{
for (int j = 0; j < 1000; j++)
{
bytes[i *
相关资源
- 人脸识别开发包免费,可商用,有演
- 用友NC开发API字典
- Web Api 通过文件流 文件到本地
- Spire API文档
- ectouch最新版JSAPI微信支付V3插
-
AN_BLE-SDKDH-C1_Teli
nk BLE SDK DeveloperHan - Servlet API中文文档
- jstl-api-1.2和jstl-impl-1.2
- hidusage.h hidpi.h 等USB开发用头文件
- LzmaLib
- OpenGL文档,api大全,可直接查询函数
- nVidia 控制面板 API
- IpHlpApi.h&IpHlpApi.lib
- 应用接口支持库1.1版eAPI
- 手机短信api接口(源代码)
- 成都MAPINFO格式电子地图
- OPC插件OPC Core Components 2.00 SDK 2.20
- ATA(ATAPI)接口指令协议硬盘基础知识
- WinAPI 函数库(大全)
- 串口操作类(justinio)
- 易语言-海康威视SDK-DEMO
- 易语言京喜拼拼API协议模块
- Win32 API大全.chm
- 300系列WIN7 USB驱动.7z
- RapidIO 2.2 Specification
- RapidIO_Rev_2.2_Specification
- 美松打印机SDK MsPrintSDK-Demo-DLL-CShare-
- 百度API车牌识别DEMO.rar
- 易语言API的用法之beep源码
- S32K144 和S32K SDK开发入门培训.pdf
评论
共有 条评论