public override void Write(byte[] buffer, int offset, int count)
{
lock (ParentStream)
{
var ParentStreamPositionToRestore = ParentStream.Position;
ParentStream.Position = ThisStart + Position;
if (Position + count > Length)
{
//count = (int)(Length - Position);
throw (new IOException(String.Format("Can't write outside the SliceStream. Trying to Write {0} bytes but only {1} available.", count, (Length - Position))));
}
try
{
base.Write(buffer, offset, count);
}
finally
{
Seek(count, SeekOrigin.Current);
ParentStream.Position = ParentStreamPositionToRestore;
}
}
}