StreamHelper.cs 568 B

1234567891011121314151617181920
  1. using System.IO;
  2. using System.Threading;
  3. namespace MediaBrowser.Controller.IO
  4. {
  5. public static class StreamHelper
  6. {
  7. public static void CopyTo(Stream source, Stream destination, int bufferSize, CancellationToken cancellationToken)
  8. {
  9. byte[] buffer = new byte[bufferSize];
  10. int read;
  11. while ((read = source.Read(buffer, 0, buffer.Length)) != 0)
  12. {
  13. cancellationToken.ThrowIfCancellationRequested();
  14. destination.Write(buffer, 0, read);
  15. }
  16. }
  17. }
  18. }