Buffered IO with BufferedStream : BufferedStream « File Directory Stream « C# / CSharp Tutorial






using System;
using System.IO;

    class Tester
    {
        

        public static void Main()
        {
            int SizeBuff = 1024;
            Stream inputStream = File.OpenRead("folder3.cs");
            Stream outputStream = File.OpenWrite("folder3.bak");
            BufferedStream bufferedInput = new BufferedStream(inputStream);
            BufferedStream bufferedOutput = new BufferedStream(outputStream);
            byte[] buffer = new Byte[SizeBuff];
            int bytesRead;

            while ((bytesRead =
            bufferedInput.Read(buffer, 0, SizeBuff)) > 0)
            {
                bufferedOutput.Write(buffer, 0, bytesRead);
            }
            bufferedOutput.Flush();
            bufferedInput.Close();
            bufferedOutput.Close();
        }
    }








15.24.BufferedStream
15.24.1.Use BufferedStream
15.24.2.Add a buffering layer to FileStream
15.24.3.Buffered IO with BufferedStream