internal void Write(System.IO.Stream s)
{
byte[] bytes = new byte[4096];
int n;
// write the header:
WriteHeader(s, bytes);
if (_Debug)
{
Console.WriteLine("{0}: writing compressed data to zipfile...", FileName);
Console.WriteLine("{0}: total data length: {1}", FileName, _CompressedSize);
}
// write the actual file data:
if (_FileData != null)
{
// use the existing compressed data we read from the extant zip archive
s.Write(_FileData, 0, _FileData.Length);
}
else
{
// rely on the compressed data we created in WriteHeader
_UnderlyingMemoryStream.Position = 0;
while ((n = _UnderlyingMemoryStream.Read(bytes, 0, bytes.Length)) != 0)
{
if (_Debug)
{
Console.WriteLine("{0}: transferring {1} bytes...", FileName, n);
for (int j = 0; j < n; j += 2)
{
if ((j > 0) && (j % 40 == 0))
System.Console.WriteLine();
System.Console.Write(" {0:X2}", bytes[j]);
if (j + 1 < n)
System.Console.Write("{0:X2}", bytes[j + 1]);
}
System.Console.WriteLine("\n");
}
s.Write(bytes, 0, n);
}
//_CompressedStream.Close();
//_CompressedStream= null;
_UnderlyingMemoryStream.Close();
_UnderlyingMemoryStream = null;
}
}