Open a Text File in C#

How to open a text file using C#
  • 1914
File.Open method is used to open a text file. 


string fileName = @"C:\Temp\MaheshTXFI.txt";     
try
{
    using (FileStream fs = File.Open(fileName, FileMode.Open, FileAccess.Write, FileShare.None))
    {
        Byte[] info = new UTF8Encoding(true).GetBytes("Add more text");
        fs.Write(info, 0, info.Length);
    }
}
catch (Exception Ex)
{
    Console.WriteLine(Ex.ToString());
}
© 2013 dotNetheaven. All rights reserved.