Looping through lines of txt file uploaded via FileUpload control

private void populateListBox() 
{
    FileUpload fu = FileUpload1; 
    if (fu.HasFile)  
    {
        StreamReader reader = new StreamReader(fu.FileContent);
        do
        {
            string textLine = reader.ReadLine();

            // do your coding 
            //Loop trough txt file and add lines to ListBox1  

        } while (reader.Peek() != -1);
        reader.Close();
    }
}

Here's a working example:

using (var file = new System.IO.StreamReader("c:\\test.txt"))
{
    string line;
    while ((line = file.ReadLine()) != null)
    {
        // do something awesome
    }
}

open the file into a StreamReader and use


while(!reader.EndOfStream) 
{ 
   reader.ReadLine; 
   // do your stuff 
}

If you want to know how to get the file/date into a stream please say in what form you get the file(s bytes)