static Stream PackageManyZip(Dictionary<string, Stream> streams)
{
byte[] buffer = new byte[6500];
MemoryStream returnStream = new MemoryStream();
var zipMs = new MemoryStream();
using (ZipOutputStream zipStream = new ZipOutputStream(zipMs))
{
zipStream.SetLevel(9);
foreach (var kv in streams)
{
string fileName = kv.Key;
//string[] name = fileName.Split("_");
//for (int i = 0; i < name.Length - 1; i++)
//{
// if (i == 0)
// fileName = name[i];
// else
// fileName += name[i];
//}
//string[] arry = name[name.Length - 1].Split('.');
//fileName += "." + arry[arry.Length - 1];
using (var streamInput = kv.Value)
{
zipStream.PutNextEntry(new ZipEntry(fileName));
while (true)
{
var readCount = streamInput.Read(buffer, 0, buffer.Length);
if (readCount > 0)
{
zipStream.Write(buffer, 0, readCount);
}
else
{
break;
}
}
zipStream.Flush();
}
}
zipStream.Finish();
zipMs.Position = 0;
zipMs.CopyTo(returnStream, 5600);
}
returnStream.Position = 0;
return returnStream;
}