File Input Output
Opens a file and prints data of that file on CommanLine...
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace OpenFile
{
class Program
{
static void Main(string[] args)
{
try
{
FileStream fs = new FileStream("D:\\MyFiles\\first.txt", FileMode.Open, FileAccess.Read, FileShare.None);
StreamReader sr = new StreamReader(fs);
string str = sr.ReadToEnd();
Console.WriteLine("The File has data as follows...\n");
Console.WriteLine(str);
sr.Close();
fs.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
