我使用7zip sdk(http://www.7-zip.org/sdk.html)来压缩一个文件文件。使用7zip sdk来压缩文件,但归档文件不是原来的,并且不能使用unrar来解压缩
它使用这种包装工作正常:
public void EncodeSingleFile(FileStream inStream, FileStream outStream) {
bool eos = false;
Int32 dictionary = 1 << 21;
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";
propIDs = new CoderPropID[]
{
CoderPropID.DictionarySize,
CoderPropID.PosStateBits,
CoderPropID.LitContextBits,
CoderPropID.LitPosBits,
CoderPropID.Algorithm,
CoderPropID.NumFastBytes,
CoderPropID.MatchFinder,
CoderPropID.EndMarker
};
properties = new object[]
{
dictionary,
posStateBits,
litContextBits,
litPosBits,
algorithm,
numFastBytes,
mf,
eos
};
Encoder encoder = new Encoder();
encoder.SetCoderProperties(propIDs, properties);
encoder.WriteCoderProperties(outStream);
Int64 fileSize = inStream.Length;
for (int i = 0; i < 8; i++)
{
outStream.WriteByte((Byte) (fileSize >> (8*i)));
}
encoder.Code(inStream, outStream, -1, -1, null);
}
不过,我有一个问题:
我只能利用7-zip.org安装7zip的外壳解压,不能用unrar解压缩。如果我设置了一些参数,那么它可能会与unrar一起工作吗?
如果我打开7zip的文件,并检查属性,我得到:
- 名称:abc.pdb
- 尺寸:1 809 920
- 包装尺寸:249 305
- 方法:LZMA:21
- 类型:LZMA
如果您在7-Zip中打开您的档案,并检查属性,它对“类型”说什么? – Cylindric
我更新了我的问题中的信息,它是:lzma – olidev
如果我使用7zip shell进行压缩,则7zip文件的类型为:7z。哼哼,奇怪....你有什么想法我做错了什么? – olidev