private void EnsureWriteable() { if (!CanWrite) { throw new NotSupportedException(SR.NotSupported_UnwritableStream); } }