I am working on visual studio 2008 what i want to do is read till the end of the file the code i am using is

StreamReader ^sr= gcnew StreamReader("example.txt");
				 String ^str;
				 while(sr->Read()!= 0)
				 {
					 str=sr->ReadLine();
					 textBox2->Text=sr->ReadLine();
					 MessageBox::Show(str);
				 }
					 sr->Close();

what could be used inside while condition that this will read till the end of the file

Edited 5 Years Ago by WaltP: Added CODE Tags -- please use them.

no the read to end function does not work with my code i want a way in which my program can read a file till the end

thanks for the reply by the way :)

yup the read to end function reads all the file and stores it in a single string i got it but i wanted the output tokened in lines

This question has already been answered. Start a new discussion instead.