Ionic zip allows me to add existing file to zip object and create a zip file. But considering that I am reading those byte[] from created zip file and sending over server, I nee
It's not really clear from your question what you're doing - but if you're just trying to avoid saving to disk and then reloading to get the data, just save to a MemoryStream
:
byte[] data;
using (MemoryStream ms = new MemoryStream())
{
zipFile.Save(ms);
data = ms.ToArray();
}
// Do whatever with data.
Alternatively, use MemoryStream.GetBuffer()
to avoid making another copy:
byte[] buffer;
int length;
using (MemoryStream ms = new MemoryStream())
{
zipFile.Save(ms);
buffer = ms.ToArray();
length = ms.Length;
}
// Now use buffer, but only up to "length"...