public int CopyTo(SKWStream destination) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } var total = 0; int len; using var buffer = Utils.RentArray <byte> (SKData.CopyBufferSize); while ((len = stream.Read((byte[])buffer, 0, buffer.Length)) > 0) { destination.Write((byte[])buffer, len); total += len; } destination.Flush(); return(total); }
public int CopyTo(SKWStream destination) { if (destination == null) { throw new ArgumentNullException(nameof(destination)); } var total = 0; int len; var buffer = ArrayPool <byte> .Shared.Rent(SKData.CopyBufferSize); try { while ((len = stream.Read(buffer, 0, buffer.Length)) > 0) { destination.Write(buffer, len); total += len; } } finally { ArrayPool <byte> .Shared.Return(buffer); } destination.Flush(); return(total); }