Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. IO;
Using icsharpcode. sharpziplib. Bzip2;
Using system. text;
Namespace common
{
/// <Summary>
/// Compressed Data Transmission
/// </Summary>
Public class unzip
{
Public unzip ()
{
}
# region returns the compressed byte array
///
// returns the compressed byte array
///
//
//
Public static byte [] compress (byte [] data)
{< br> If (Data = NULL | data. length = 0)
{< br> return NULL;
}
Memorystream instream = new memorystream (data, 0, Data. Length );
Memorystream outstream = new memorystream ();
Bzip2.compress (instream, outstream, false, Data. Length );
Byte [] result = outstream. toarray ();
Instream. Close ();
Outstream. Close ();
Return result;
}
# Endregion
# Region returns the extracted byte array
/// <Summary>
/// Return the extracted byte array
/// </Summary>
/// <Param name = "data"> original byte array </param>
/// <Returns> </returns>
Public static byte [] decompress (byte [] data)
{
If (Data = NULL | data. Length = 0)
{
Return NULL;
}
Memorystream instream = new memorystream (data, 0, Data. Length );
Memorystream outstream = new memorystream ();
Bzip2.decompress (instream, outstream, false );
Byte [] result = outstream. toarray ();
Instream. Close ();
Outstream. Close ();
Return result;
}
# Endregion
}
}