elena1234

CopyBinaryFile_withBuffer

Jan 17th, 2021 (edited)
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3.  
  4. namespace CopyBinaryFile_withBuffer
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             using (FileStream reader = new FileStream(@"..\..\..\university.png", FileMode.Open))
  11.             using (FileStream writer = new FileStream(@"..\..\..\newFile.png", FileMode.Create))
  12.             {
  13.                 byte[] buffer = new byte[4096];
  14.                 int bytesRead;
  15.                 while ((bytesRead = reader.Read(buffer, 0, buffer.Length)) > 0)
  16.                 {                
  17.                     writer.Write(buffer, 0, bytesRead);
  18.                 }
  19.             }
  20.         }
  21.     }
  22. }
  23.  
Add Comment
Please, Sign In to add comment