I need to zip and unzip string
Here is code:
public static byte[] ZipStr(String str)
{
using (MemoryStream output = new MemoryStream())
using (DeflateStream gzip = new DeflateStream(output, CompressionMode.Compress))
using (StreamWriter…
I'm trying to use deflate/gzip streams in C# but it appears that the files after compression are bigger than before.
For example, I compress a docx file of 900ko, but it produce a 1.4Mo one !
And it does it for every file I tried.
May be I am wrong…
So here's a strange one. I have this method to take a Base64-encoded deflated string and return the original data:
public static string Base64Decompress(string base64data)
{
byte[] b = Convert.FromBase64String(base64data);
using (var orig =…
I'm trying to compress some data in mono like this:
public static string Save(FlightProgram program, bool compressed)
{
using (MemoryStream ms = new MemoryStream())
{
BinaryFormatter f = new BinaryFormatter();
if…
I have a TcpClient class on a client and server setup on my local machine. I have been using the Network stream to facilitate communications back and forth between the 2 successfully.
Moving forward I am trying to implement compression in the…
I would like to be able to read the Dynamics NAV 2013 Table Metadata directly from the SQL Server database without requiring the NAV Development Environment.
I can view the binary SQL "image" BLOB columns with a query like the following (filter as…
I'm reading data (an adCenter report, as it happens), which is supposed to be zipped. Reading the contents with an ordinary stream, I get a couple thousand bytes of gibberish, so this seems reasonable. So I feed the stream to DeflateStream.
First,…
I'm trying to do custom serialization/deserialization of an object as well as compressing/decompressing the serialized data with DeflateStreams. I originally did this for more complex objects but cut it down to try and figure out the problem,…
I'm playing around with the ability to create pdf files through C# code. I have been looking at the PDF specifications and have been able to create a working PDF file, done by taking strings of data and encoding them into byte arrays using the UTF8…
Using both httpbin and Postman Echo (which appear to be the same service, effectively), I'm able to successfully get a gzip'd response with their testing endpoint like this:
var cli = new HttpClient(new HttpClientHandler
{
AutomaticDecompression…
I have a Zip archive with a large (important) file that will not extract. All Zip utilities that I've tried, including those that claim to recover/fix broken Zip archives are unable to extract the file containing the corrupted zlib compressed data.…
I need a zlib deflate compressed stream. In my implementation I must use a single stream over the entire session. during this session small chunks of data will be passed through the compressed stream. Everytime a chunk is passed it must be sent in…
I have a function I use for aggregating streams from a zip archive.
private void ExtractMiscellaneousFiles()
{
foreach (var miscellaneousFileName in _fileData.MiscellaneousFileNames)
{
var fileEntry =…
I'm using mono to inflate/deflate bytes. Here is the code:
public static byte[] Inflate(byte[] data)
{
using (MemoryStream inStream = new MemoryStream(data))
{
using (MemoryStream outStream = new MemoryStream())
…
I wonder if anyone can shed some light on an issue that is driving me nuts:
I am writing a compression decompression test class. To test it, I am serializing a dataset to a memory stream, compressing it, and uncompressing it and comparing the…