public override void Write(byte[] buffer, int offset, int count)
{
if (_Disposed) throw new ObjectDisposedException(GetType().Name);
if (buffer==null) throw new ArgumentNullException("buffer");
if (offset<0 || offset>buffer.Length) throw new ArgumentOutOfRangeException("offset");
if (count<0 || count>buffer.Length-offset) throw new ArgumentOutOfRangeException("count");
if (_RealStream != null)
try {
_RealStream.Write(buffer, offset, count);
}
catch {
_RealStream.Close();
_RealStream = null;
}
byte[] chunk = new byte[count];
System.Buffer.BlockCopy(buffer, offset, chunk, 0, count);
_Buffers.Add(chunk);
_TotalSize += count;
}