使用7zip sdk压缩文件,但存档文件不是原始文件,无法使用unrar解压缩

我正在使用7zip sdk(http://www.7-zip.org/sdk.html)来压缩文件。

它使用这个包装工作正常:

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))); } encoder.Code(inStream, outStream, -1, -1, null); 

}

但是,我遇到了一个问题:

我只能使用从7-zip.org安装的7zip shell解压缩它,无法用unrar解压缩。 是否可以设置一些参数,它也适用于unrar?

如果我在7zip中打开文件并检查属性,我得到:

  • 名称:abc.pdb
  • 大小:1 809 920
  • 包装尺寸:249 305
  • 方法:LZMA:21
  • 输入:lzma

在CodeProject上有一个使用SDK为7z创建C#接口的例子。 他还提到现在可以使用COM来对抗DLL,但我不知道它是如何工作的。

在代码项目上查看7-Zip存档DLL的C#(.NET)接口 。

如果您正在寻找创建RAR存档,您可能会因为它是封闭源而运气不好。 您可以使用外部库,但压缩算法是专有的。

来自RAR Wiki页面 :

RAR文件只能使用商业软件WinRAR,RAR和获得许可人Alexander Roshal许可的软件创建

我建议调查许多未受阻碍的替代品之一。