7zip compress network stream

前端 未结 2 1049
北恋
北恋 2021-01-06 13:13

I will like to compress a file before sending it through the network. I think the best approach is 7zip because it is free and open source.

How I use 7zip wi

2条回答
  •  -上瘾入骨i
    2021-01-06 13:31

    Have you considered an alternate library - one that doesn't even require 7-Zip to be installed / available?

    From the description posted at http://dotnetzip.codeplex.com/ :

    creating zip files from stream content, saving to a stream, extracting to a stream, reading from a stream

    Unlike 7-Zip, DotNetZip is designed to work with C# / .Net.

    Plenty of examples - including streaming, are available at http://dotnetzip.codeplex.com/wikipage?title=CS-Examples&referringTitle=Examples .

    Another option is to use the 7-Zip Command Line Version (7z.exe), and write to/read from standard in/out. This would allow you to use the 7-Zip file format, while also keeping all of the core work in native code (though there likely won't be much of a significant difference).

    Looking back at SevenZipSharp:

    Since the 0.29 release, streaming is supported.

    Looking at http://sevenzipsharp.codeplex.com/SourceControl/changeset/view/59007#364711 :

    it seems you'd want this method:

    public void CompressStream(Stream inStream, Stream outStream)
    

    Thank you for considering performance here! I think way too many people would do exactly what you're trying to avoid: compress to a temp file, then do something with the temp file.

提交回复
热议问题