Skip to content
David Cumps

FileStream Class

Part of my 2008 study notes for exam 70-536 (.NET Framework 2.0).

Overview

  • Provides a file specific implementation of a Stream.

Good practice

  • Remember to call Close on a stream.

Examples

Read a File

// FileStream is simply a stream around a file, overriding Stream methods
FileStream a = new FileStream(@"C:\Public\Test.txt", FileMode.Open);
 
while (a.Position != a.Length)
{
    Console.Write((char)a.ReadByte());
}

You May Also Like

ArrayList Class

Resizeable, unordered, index-based collection. Suffers from boxing/unboxing when working with value types. Implements IEnumerator, allowing foreach…

BitArray Class

Contains an array of true/false values. Resizable through the Length property. Supports bitwise operations.