Using 7zip sdk to compress the file, but the archive file is not original and cannot be unpacked using unrar

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

it works fine with this shell:

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 a problem:

I can only unzip it using the 7zip shell installed from 7-zip.org, cannot unzip it with unrar. is it possible if I set some parameters and it will work with unrar too?

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

  • Name: abc.pdb
  • Size: 1 809 920
  • Package Size: 249,305
  • Method: LZMA: 21
  • Type: lzma
+1
source share
2 answers

CodeProject has an example of someone creating a C # interface for 7z using the SDK. He also mentions that COM can now be used for a DLL, but I don’t know how this works.

Check out the C # Interface (.NET) for DLL files with a 7-digit archive in the Code project.

+1
source

If you want to create a RAR archive, you might be out of luck as it is closed. You may be using external libraries, but the compression algorithm is proprietary.

From the RAR Wiki Page :

RAR files can only be created using commercial WinRAR software, RAR and software licensed by licensor Alexander Roshal

I would suggest exploring one of the many unspent alternatives.

0
source

Source: https://habr.com/ru/post/1384080/


All Articles