资源简介
最简单的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 *
相关资源
- WPS接口文件
- 小说api.xlsx
- 江苏省shp.7z文件包括地级市公路河流
- 基于 QT5 百度语音API 图灵机器人API 的
- 密码破解字典.7z
- 百度地图API自定义点路书,路书点击
- d197e572245b6c32945b6045563abd70.7z
- API-MS-WIN一系列丢失DLL打包
- js调用阿里云api签名算法
- 着陆控制系统.7z
- revit二次开发——普通钢筋(revitAPI钢
- esp8266的SDK开发 TCP、UDP服务器端
- 亿图图示V9.0+通用破解挂载模块.7z
- jtopo实现自动树形布局配详细注释
- 在delphi xe7中调用七牛云存储api上传演
- testRoll.7z
- 博世BMA456 传感器API 官方例程.zip
- Proteus8.9 仿真STM32407ZGT6系列基础模板
- 在树莓派安装神经计算棒sdk步骤
- Hi3531D V100R001C02SPC040 sdk 百度云下载2
- Hi3536D V100R001C02SPC020 sdk 百度云
- GprinterSDK IOS 附带官方demo
- wps_symbol_fonts.7z
- 网易新闻apicloud源码
- zepto中文api
- system权限进程以user权限调用进程
- 微软API放大镜
- CyAPI库包括CAPI.lib及CyAPI.hcyioct.h
- linux下读写ini配置文件(与windows API一
- API接口模板-含Word和excel
评论
共有 条评论