print?public void Base64Test()
{
string baseStr = "eJyVjMENgDAMA1fpBMjnIkp3ZzZEpAa1PLmXY10sDdqBqr54Ww5AthG7zxJYa0MYr9p7bPFnK/uqjCj06y7JfHwAX3AhhA==";
// Base64解碼
byte[] baseBytes = Convert.FromBase64String(baseStr);
// Inflater解壓
string resultStr = Decompress(baseBytes);
Console.WriteLine(resultStr);
}
/// <summary>
/// Inflater解壓
/// </summary>
/// <param name="baseBytes"></param>
/// <returns></returns>
public string Decompress(byte[] baseBytes)
{
string resultStr = string.Empty;
using (MemoryStream memoryStream = new MemoryStream(baseBytes))
{
using (InflaterInputStream inf = new InflaterInputStream(memoryStream))
{
using (MemoryStream buffer = new MemoryStream())
{
byte[] result = new byte[1024];
int resLen;
while ((resLen = inf.Read(result, 0, result.Length)) > 0)
{
buffer.Write(result, 0, resLen);
}
resultStr = Encoding.Default.GetString(result);
}
}
}
return resultStr;
}
public void Base64Test()
{
string baseStr = "eJyVjMENgDAMA1fpBMjnIkp3ZzZEpAa1PLmXY10sDdqBqr54Ww5AthG7zxJYa0MYr9p7bPFnK/uqjCj06y7JfHwAX3AhhA==";
// Base64解碼
byte[] baseBytes = Convert.FromBase64String(baseStr);
// Inflater解壓
string resultStr = Decompress(baseBytes);
Console.WriteLine(resultStr);
}
/// <summary>
/// Inflater解壓
/// </summary>
/// <param name="baseBytes"></param>
/// <returns></returns>
public string Decompress(byte[] baseBytes)
{
string resultStr = string.Empty;
using (MemoryStream memoryStream = new MemoryStream(baseBytes))
{
using (InflaterInputStream inf = new InflaterInputStream(memoryStream))
{
using (MemoryStream buffer = new MemoryStream())
{
byte[] result = new byte[1024];
int resLen;
while ((resLen = inf.Read(result, 0, result.Length)) > 0)
{
buffer.Write(result, 0, resLen);
}
resultStr = Encoding.Default.GetString(result);
}
}
}
return resultStr;
}
其中InflaterInputStream的類來自於ICSharpCode.SharpZipLib.dll中。