使用7zip sdk压缩文件,但存档文件不是原始文件,无法使用unrar解压 [英] using 7zip sdk to compress a file, but the archive file is not as original and can not decompress using unrar

查看:31
本文介绍了使用7zip sdk压缩文件,但存档文件不是原始文件,无法使用unrar解压的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am using 7zip sdk (http://www.7-zip.org/sdk.html) to compress a file.

使用此包装器可以正常工作:

it works fine using this wrapper:

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);   

}

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

However, I have got a problem:

我只能使用从 7-zip.org 安装的 7zip shell 解压它,不能用 unrar 解压.如果我设置了一些参数并且它也适用于 unrar 是否可行?

I can only decompress it using 7zip shell installed from 7-zip.org, can not decompress with unrar. is that possible if I set some parameters and it will work with unrar as well?

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

If I open the file in 7zip and check the properties, I got:

  • 名称:abc.pdb
  • 尺寸:1 809 920
  • 包装尺寸:249 305
  • 方法:LZMA:21
  • 类型:lzma

推荐答案

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

There is an example on CodeProject of someone creating a C# interface for 7z using the SDK. He also mentions it is now possible to use COM against the DLL's, but I don't know how that works.

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

这篇关于使用7zip sdk压缩文件,但存档文件不是原始文件,无法使用unrar解压的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆