原方法把level当成size传进去了,会报错
public static void Compress(Stream inStream, Stream outStream, bool isStreamOwner, int level)
{
if (inStream == null || outStream == null) {
throw new Exception("Null Stream");
}
try {
using (GZipOutputStream bzipOutput = new GZipOutputStream(outStream, level)) {
bzipOutput.IsStreamOwner = isStreamOwner;
Core.StreamUtils.Copy(inStream, bzipOutput, new byte[4096]);
}
} finally {
if (isStreamOwner) {
// outStream is closed by the GZipOutputStream if stream owner
inStream.Dispose();
}
}
}
建议修改为
public static void Compress(Stream inStream, Stream outStream, bool isStreamOwner, int level)
{
if (inStream == null || outStream == null) {
throw new Exception("Null Stream");
}
try {
using (GZipOutputStream bzipOutput = new GZipOutputStream(outStream)) {
bzipOutput.SetLevel(level);
bzipOutput.IsStreamOwner = isStreamOwner;
Core.StreamUtils.Copy(inStream, bzipOutput, new byte[4096]);
}
} finally {
if (isStreamOwner) {
// outStream is closed by the GZipOutputStream if stream owner
inStream.Dispose();
}
}
}
原方法把level当成size传进去了,会报错
建议修改为