我使用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