This code opens a text file called "tenfile.txt", reads each line of text, adds it to a list box as an item, and continues doing so until it reaches the end of the file. It then closes and disposes of the file stream.
This code opens a text file called "tenfile.txt", reads each line of text, adds it to a list box as an item, and continues doing so until it reaches the end of the file. It then closes and disposes of the file stream.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
This code opens a text file called "tenfile.txt", reads each line of text, adds it to a list box as an item, and continues doing so until it reaches the end of the file. It then closes and disposes of the file stream.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online from Scribd
string a; System.IO.StreamReader docFile = new System.IO.StreamReader("tenfile.txt"); a = docFile.ReadLine(); while (a != null) { listBox1.Items.Add(a); a = docFile.ReadLine(); } docFile.Close(); docFile.