Hi gurus,
I need to create a byte array, with the zip of multiple byte arrays. I don't want to generate files during the process. I have coded what is displayed next:
__________________________________________________ ______________________________
using ICSharpCode.SharpZipLib.Zip;

(...)

FileStream tempFileStream = new FileStream(@"C:\test.zip", FileMode.Open, FileAccess.ReadWrite, FileShare.None);

Stream compressedContents = new MemoryStream();
ZipOutputStream zipOutput = new ZipOutputStream(compressedContents);
zipOutput.SetLevel(5);

for (int i = 0; i < attachments.Count; i++) //attachments -> byte [][]
{

ZipEntry entry = new ZipEntry(attachsNames);
entry.DateTime = DateTime.Now;
entry.Size = attachments.Length;
zipOutput.PutNextEntry(entry);
zipOutput.Write(attachments, 0, attachments.Length);

}

zipOutput.Finish();
zipOutput.Flush();

byte[] buffer = new byte[compressedContents.Length];
compressedContents.Read(buffer, 0, (int)compressedContents.Length);

tempFileStream.Write(buffer, 0, (int)compressedContents.Length);
tempFileStream.Close();

zipOutput.Close();
compressedContents.Close();
__________________________________________________ ______________________________

The file defined is only for testing purposes. When I try to open it, appears the usual error when a file is broken: "can not open test.zip as an archive".

If variable compressedContents is directly a FileStream, instead of a MemoryStream, the test file is created correctly. The problem may be on the way I use the memoryStream or the buffer...But it seems all correct for me!! Any solutions for this?

Cumps
Supertreta