In the previous blog (Reading Text File Using StreamReader Class), I demonstrated the use of StreadReader class to read text file. The System.IO.File class also provide us with a couple of ways to read text file as well.
We will use it's capability in this blog to read the data from text file and load it directly into a combo box.
Code sample:
string[] theStates;
theStates=System.IO.File.ReadAllLines(txtFilename.Text);
cboStates.Items.AddRange(theStates);
A sample application is available here.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment