VB.NET - Open File From ListView - Asked By Tony Reilly-Cooper on 12-Mar-13 03:32 PM

Evening Guys and Girls
I have a problem I really need some help with. 

So I have a vb.net application where the contents of a directory are listed.

It has a listbox which lists the files within a directory. I want to be able to click on the files (.rtf) and their contents be loaded in to the rich text box which is next to the listbox. 

I can get the listbox to populate with the files but cant seem to get the contents to load into the richtxt box. I am only dealing with RTF files. 

Hope someone can help because I am at a complete loss. 

Cheers Guys and Girls! 
Tom Wilson replied to Tony Reilly-Cooper on 12-Mar-13 08:23 PM
Assuming the listbox contains a file path, try:

Imports System.IO
'some event such as listbox SelectedIndexChanged event

Dim sr as new StreamReader(Listbox1.SelectedItem.Tostring)

Richtextbox1.RTF = sr.ReadtoEnd