The text can be read and sorted as given in solution 1 by
OriginalGriff. Now, to use
OpenFileDialog
and to display in
ListBox
, use the following code in the
Click
event of the
Button
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.ShowDialog();
string[] dataFromFile = System.IO.File.ReadAllLines(openFileDialog.FileName);
Array.Sort(dataFromFile);
listBox1.DataSource= dataFromFile;