Questions tagged [deflatestream]

Microsoft .NET built-in support for standards-compliant Deflate algorithm (compress and decompress).

DeflateStream is a Microsoft .NET Class that provides standards-compliant support for the "DEFLATE" compression algorithm.

78 questions
4
votes
4 answers

Zip a MemoryStream for an email attachment

I'm trying to zip an XML tree and use it as an email attachment. The sending of the email with an attachment succeeds, but the zip file created is always corrupt – it is not a valid zip file but does contain binary data. The problem is recreated as…
acraig5075
  • 10,588
  • 3
  • 31
  • 50
3
votes
1 answer

GzipStream (.net 4.0) 4GB problem

I am having trouble programmatically unzipping a 3GB (7GB uncompressed) gzip file using the built in .net 4.0 Gzip and Deflate Classes. My understanding is that they should both support files over 4GB, but they seem to not be working. When I…
Glenn
  • 1,234
  • 2
  • 19
  • 33
3
votes
1 answer

Compressed content in a byte array to uncompressed in a string

How can we create a simple function to take the compressed content from an array of byte (compressed with Deflate method, ANSI encoded) and express it in a string? I go with this one : public string UnzipString3(byte[] byteArrayCompressedContent) …
Gaël
  • 117
  • 1
  • 2
  • 17
3
votes
2 answers

Deflating data from MSZIP format

I'm trying to read a compressed binary .x mesh file but my decompression is failing. The file is basically some directx header info and then a bunch of data in MSZIP format (i.e. 2 bytes are an int blockSize, 2 bytes are a "magic number" and then…
3
votes
2 answers

C# - GZipStream magic number incorrect?

So, I'm trying to make a program which turns a computer into a proxy using this. It all works well, except for gzip/deflate pages. Whenever I try to uncompress, I get an InvalidDataException stating the magic number in the GzipHeader is incorrect. I…
Adam M
  • 113
  • 3
  • 13
2
votes
3 answers

Does DeflateStream "skip" decompression if the data was not originally compressed?

I'm not familiar with the internals of DeflateStream, but I need to store files in a Vendor's DB system that uses DeflateStream on binary attachments. The first thing I noticed was that all of my files were 10-50% BIGGER after compression, but I…
plyawn
  • 413
  • 4
  • 12
2
votes
1 answer

Reading using DeflateStream doesn't match expected size

I'm writing a set of discrete binary data to a stream and then to disk. I'm using a buffered file stream to reduce the disk usage. BinaryWriter -> DeflateStream -> FileStream (buffered) The data set consists of a header part (with some info) and…
Nicke Manarin
  • 3,026
  • 4
  • 37
  • 79
2
votes
2 answers

Yet another DeflateStream decompression problem (using using and memory streams)

Firstly, I'm noticing that compressing the object requires more bytes then purely representing the object in binary form. (228 vs 166). Secondly, I can't seem to decompress it. Also, I can't use the nice CopyTo functionality since I don't have…
user420667
  • 6,552
  • 15
  • 51
  • 83
2
votes
1 answer

How to get the length of the compressed data from DeflateStream?

The following is a simple compression method I wrote using DeflateStream: public static int Compress( byte[] inputData, int inputStartIndex, int inputLength, byte[] outputData, int outputStartIndex, int outputLength) { …
user788454
2
votes
1 answer

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…
Damn Vegetables
  • 11,484
  • 13
  • 80
  • 135
2
votes
1 answer

Decompress body request with C# in asp.net mvc already compressed with pako library JS

I have an asp.net mvc app and want to compress body of the request in the view with Pako library (using gzip and deflate encoding) and decompress the body request before arriving to the controller using OnActionExecuting and…
2
votes
0 answers

How can I find the end of a DEFLATE stream in a larger byte array?

I'm working with an arbitrary array of bytes which contains two raw DEFLATE streams concatenated. There is no metadata that tells where the first stream ends or the next one begins. Is there a way to decompress the first stream and know where it…
2
votes
0 answers

How to read meta data of an epub with XmlReader and DeflateStream in a powershell Cmdlet

I've tried to write a commandlet for getting meta information from an epub file. I would like to use the commandlet like this: Get-ChildItem '*.epub' | Get-EpubMetaInfo | %{ Rename-Item $_.File "$($_.Author) - $($_.Title).epub" } So…
Mattia72
  • 825
  • 1
  • 8
  • 23
2
votes
1 answer

DeflateStream / GZipStream to CryptoStream and vice versa

I want to to compress and encrypt a file in one go by using this simple code: public void compress(FileInfo fi, Byte[] pKey, Byte[] pIV) { // Get the stream of the source file. using (FileStream inFile = fi.OpenRead()) { …
PePe
  • 65
  • 1
  • 6
1
vote
3 answers

Can I use less memory when using DeflateStream?

My application needs to decompress files which contain a lot of Deflate compressed blocks (as well as other types of compression and encryption). Memory profiling shows that the deflate stream constructor is responsible for allocating the majority…
Craig Gidney
  • 17,763
  • 5
  • 68
  • 136