Use BufferedStream : BufferedStream « File Directory Stream « C# / CSharp Tutorial






using System;
using System.IO;

public class MainClass
{
    public static int Main(string[] args)
    {

    FileStream dumpFile = new FileStream("Dump.dat", FileMode.Create, FileAccess.ReadWrite);
    BufferedStream myFileBuffer = new BufferedStream(dumpFile);
    
    byte[] str = {127, 0x77, 0x4, 0x0, 0x0, 0x16};
    myFileBuffer.Write(str, 0, str.Length);

    // add changes to file.
    myFileBuffer.Close();  // Flushes.
    dumpFile.Close();  // Flushes.

    return 0;
    }
}








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