This example shows how to open files for reading or writing, how to load and save files using FileStream in C#. To open file create instance of
FileStream class with
FileMode and
FileAccess enumerations as parameters.
using System.IO;
FileStream fileStream = new FileStream(@"c:\file.txt", FileMode.Open);
try
{
// read from file or write to file
}
finally
{
fileStream.Close();
}