Here we will discuss how we can read and write from a text file in Asp.net.
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:
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.
File.WriteAllLines(strPath,
Details);