public byte[] Compress(Stream inputStream) { using (var outputStream = new MemoryStream()) using (var bzip2 = new BZip2OutputStream(outputStream)) { inputStream.WriteTo(bzip2); return outputStream.ToArray(); } }
public byte[] Compress(Stream inputStream) { using (var outputStream = new MemoryStream()) using (var zlibStream = new ZlibStream(outputStream, CompressionMode.Compress)) { inputStream.WriteTo(zlibStream); return outputStream.ToArray(); } }
public override void Store(Stream stream, FileSystemObject fso) { CreateFolder(fso.FolderName); using (var fs = new FileStream(fso.FullName, FileMode.Create, FileAccess.Write)) { stream.WriteTo(fs); } }
public byte[] Compress(Stream inputStream) { byte[] result; MemoryStream outputStream = null; try { outputStream = new MemoryStream(); using (var deflateStream = new DeflateStream(outputStream, CompressionMode.Compress)) { inputStream.WriteTo(deflateStream); result = outputStream.ToArray(); } } finally { if (outputStream != null) { outputStream.Dispose(); } } return result; }