Read the text file by line

xiaoxiao2021-03-06  77

If you need to read a text file by line, you can use the System.io.StreamReader object and its PEEK and READLINE methods, such as the following example:

Private void ReadtextFile (String FileName)

{

// Open and read the text file line by line

StreamReader Srfile = New StreamReader (filename, true);

While (srfile.peek ()> -1) // Check Eof

{

String sline = srfile.readline (); // r on line

// ...

}

Srfile.close ();

}

转载请注明原文地址:https://www.9cbs.com/read-94998.html

New Post(0)