Net Encryption Library
CompressStream Method
Example 






KellermanSoftware.NetEncryptionLibrary Namespace > Encryption Class : CompressStream Method
Compress a stream using the specified compression type
Syntax
'Declaration
 
Public Function CompressStream( _
   ByVal compressionType As CompressionType, _
   ByVal input As System.IO.Stream _
) As System.IO.Stream
'Usage
 
Dim instance As Encryption
Dim compressionType As CompressionType
Dim input As System.IO.Stream
Dim value As System.IO.Stream
 
value = instance.CompressStream(compressionType, input)
public System.IO.Stream CompressStream( 
   CompressionType compressionType,
   System.IO.Stream input
)
public function CompressStream( 
    compressionType: CompressionType;
    input: System.IO.Stream
): System.IO.Stream; 
public function CompressStream( 
   compressionType : CompressionType,
   input : System.IO.Stream
) : System.IO.Stream;
public: System.IO.Stream* CompressStream( 
   CompressionType compressionType,
   System.IO.Stream* input
) 
public:
System.IO.Stream^ CompressStream( 
   CompressionType compressionType,
   System.IO.Stream^ input
) 

Parameters

compressionType
input
Example
Encryption encryption = new Encryption(); //Trial Mode
//Encryption encryption = new Encryption("place user name here", "place license key here"); //License Mode
 
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 1024; i++)
    sb.AppendLine("This is a test");
 
File.WriteAllText("input.txt", sb.ToString());
 
using (FileStream inputStream = new FileStream("input.txt", FileMode.Open, FileAccess.Read))
{
    Stream compressedStream = encryption.CompressStream(CompressionType.MiniLZO, inputStream);
    Console.WriteLine("{0} bytes compressed to {1} bytes with MiniLZO", inputStream.Length, compressedStream.Length);
}
Dim encryption As New Encryption() 'Trial Mode
'Dim encryption As New Encryption("place user name here", "place license key here") 'License Mode
 
Dim sb As New StringBuilder()
For i As Integer = 0 To 1023
    sb.AppendLine("This is a test")
Next i
 
File.WriteAllText("input.txt", sb.ToString())
 
Using inputStream As New FileStream("input.txt", FileMode.Open, FileAccess.Read)
    Dim compressedStream As Stream = encryption.CompressStream(CompressionType.MiniLZO, inputStream)
    Console.WriteLine("{0} bytes compressed to {1} bytes with MiniLZO", inputStream.Length, compressedStream.Length)
End Using
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Encryption Class
Encryption Members