c# - Easiest way to Add lines wrong a .txt file to a list -


at moment opening .txt file twice, once number of lines, second add line list as how lines there in .txt file. there easier/better way this?

this code:

list<streamreader> lijst = new list<streamreader>(); streamreader something1 = new streamreader("c:\\something123.txt"); streamreader something2 = new streamreader("c:\\something123.txt");  lijst.add(something1); lijst.add(something2); {     int l = 0;     while (lijst[1].readline() != null)      {          l++;         downloadlinks.add(lijst[1].readline());     }      (int = 0; < l; i++)     {         string line = lijst[0].readline();         alist.add(line);     }  } 

i want put lines of file in list

then working working hard. can use file.readlines, yields ienumerable<string> , pass list<string>:

var alltextlines = new list<string>(file.readlines(path)); 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -