We can read the file using File class as follows,
Code:
//Read a txt file
string[] str = File.ReadAllLines(@"C:/test.txt");
if (str.Length > 0)
{
for (int i = 0; i < str.Length; i++)
{
MessageBox.Show(str[i]);
}
}
We can write the file using StreamWriter as follows,
Code:
//Write a txt file
StreamWriter sw = new StreamWriter("C:/test.txt");
string str = "Test for writing";
sw.WriteLine(str);
sw.Close();
__________________
S.VinothkumaR
Behind me is infinite power,
Before me is Endless Possibility,
Around me is Boundless Opportunity,
Why should I fear!