I downloaded the SDK 7zip from here.
Then I used this code to compress a file to 7zip:
private static void CompressFileLZMA(string inFile, string outFile)
{
Encoder coder = new SevenZip.Compression.LZMA.Encoder();
using (FileStream input = new FileStream(inFile, FileMode.Open))
using (FileStream output = new FileStream(outFile, FileMode.Create))
{
coder.Code(input, output, -1, -1, null);
output.Flush();
}
}
I tried both the SDK versions 9.20 and 9.22 beta on the site.
The compression seems working to compress my file from: 1.6 MB to 239 KB.
However, if I use WinRar or 7zip to decompress. the archive file is not recognized by them, the error is like
“unknown archive file or damaged file”
Any idea for this?
You can try to use 7zSharp wrapper or at least analyze wrappers code how everything is done.
Code to compress file(taken from 7zSharp):