I push a button and a list all the files in my given path appears in a listbox.
IEnumerable<string> files = System.IO.Directory.EnumerateFiles(@"C:\Desktop\Stuffs\Dummi", "*.*", System.IO.SearchOption.AllDirectories);
foreach (var f in files)
{
lbz.Items.Add(String.Format("{0}", f));
I want to be able to select a file from the list and open it’s contents in a text box below the listbox.
SteveDog’s answer should work fine for small files.
If you have large files, this may lock up the UI as the file’s contents are read. In that case you could use a
BackgroundWorkerto read the file: