txtEditor.Text = File.ReadAllText(openFileDialog.FileName);
You are opening the file from the
openFileDialog
instead of the one in the selected item of the
ListBox
.
[edit]
The code should be something like:
private void lbFiles_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
object item = lbFiles.SelectedItem;
if (item == null)
{
txtEditor.Text = "No Item Selected";
}
else
{
txtEditor.Text = File.ReadAllText(item.ToString());
}
}
[/edit]