Advertisement
Guest User

Untitled

a guest
Aug 9th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. public static byte[] CompressByDeflateDotNetZip(string input, string fileName)
  2.     {
  3.       using (var msInut = new MemoryStream(Encoding.UTF8.GetBytes(input)))
  4.       {
  5.         using (var compressedStream = new MemoryStream())
  6.         {
  7.           using (var zipOutStream = new ZipOutputStream(compressedStream))
  8.           {
  9.             zipOutStream.CompressionMethod = CompressionMethod.Deflate;
  10.             zipOutStream.EnableZip64 = Zip64Option.AsNecessary;
  11.             zipOutStream.PutNextEntry(fileName);
  12.             msInut.CopyTo(zipOutStream);
  13.           }
  14.           return compressedStream.ToArray();
  15.         }
  16.       }
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement