public static string DecompressString(string base64String)
{
if (base64String.Length == 0)
{
return string.Empty;
}
string str = string.Empty;
try
{
byte[] buffer = Convert.FromBase64String(base64String);
int count = BitConverter.ToInt32(new byte[] { buffer[buffer.Length - 4], buffer[buffer.Length - 3], buffer[buffer.Length - 2], buffer[buffer.Length - 1] }, 0);
using (MemoryStream stream = new MemoryStream(buffer, 0, buffer.Length))
{
using (GZipStream stream2 = new GZipStream(stream, CompressionMode.Decompress))
{
byte[] buffer2 = new byte[count];
stream2.Read(buffer2, 0, count);
return encode.GetString(buffer2);
}
}
}
catch
{
}
return str;
} RT
这行.
楼主看下这个链接
http://blog.csdn.net/downmoon/archive/2006/02/22/606592.aspx
// Read the footer to determine the length of the destiantion file
quartetBuffer = new byte[4];
int position = (int)sourceStream.Length - 4;
sourceStream.Position = position;
sourceStream.Read ( quartetBuffer, 0, 4 );
sourceStream.Position = 0;
int checkLength = BitConverter.ToInt32 ( quartetBuffer, 0 );