C Method of Reading File Line by Line
- 2021-07-01 08:06:02
- OfStack
This paper illustrates the method of reading files line by line by C #. Share it for your reference. The details are as follows:
Here, C # is used to read files line by line, which is very useful for reading large files.
StreamReader sr = new StreamReader("fileName.txt");
string line;
while((line= sr.ReadLine()) != null) {
Console.WriteLine("xml template:"+line);
}
if (sr != null)sr.Close();
//should be in a "finally" or "using" block
I hope this article is helpful to everyone's C # programming.