Ethernal_Five

C# - Read File into Listbox

Sep 5th, 2011
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1.     static void ReadFile(string _file)
  2.     {
  3.         List<string> lines = new List<string>();
  4.         using (StreamReader r = new StreamReader(_file))
  5.         {
  6.             string line;
  7.             while ((line = r.ReadLine()) != null)
  8.             {
  9.                 lines.Add(line);
  10.             }
  11.         }
  12.         foreach (string s in lines)
  13.         {
  14.             listBox1.Items.Add(s);
  15.         }
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment