2021年4月4日星期日

DeflateStream.Flush() has no functionality?

I was trying to compress a byte array using DeflateStream. After wring the data, I was looking for a way to close the compression (mark as done). At first, I tried Dispose() then Close(), but those made the result MemoryStream unreadable. Then I thought I may need to Flush(), but the description said "The current implementation of this method has no functionality"

enter image description here

But it seems that without Flush(), the result seems empty. What does it mean that "The current implementation of this method has no functionality"?

    static void Main(string[] args)      {          byte[] result = Encoding.UTF8.GetBytes("わたしのこいはみなみのかぜにのってはしるわ");          var output = new MemoryStream();          var dstream = new DeflateStream(output, CompressionLevel.Optimal);          dstream.Write(result, 0, result.Length);          var compressedSize1 = output.Position;          dstream.Flush();          var compressedSize2 = output.Position;  

enter image description here

https://stackoverflow.com/questions/66947942/deflatestream-flush-has-no-functionality April 05, 2021 at 11:34AM

没有评论:

发表评论