Tuesday, January 25, 2011

How to read and write from a Text file in asp.net?

Here you will get a string array while reading all the lines and it will store one line to an array element in C#.Net.
And once you will get the array then you can modify what ever you want and then you can Write the whole array to the file.

Here is the code:
string[] Details = new string[0];
string strPath = @"C:\myfile.txt";
if (File.Exists(strPath))
Details = File.ReadAllLines(strPath);
//Here you will get in the form of array
Details [0] = "password^###~" + "What ever text you want";
Here you can write the whole array to the file.
Details );