DoubleClick a ListView Control Selected Item to Open a File
Posted on 2004-11-08
I have a listview control that lists some files. I want to be able to doubleclick on the files and have them open.
The code I am trying to use is:
Private Sub listviewLocalFile_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles listviewLocalFile.DoubleClick
RunProgram.StartInfo.FileName = "listviewLocalFile.SelectedItems(0).Text" 'SET THE FILE TO OPEN
RunProgram.StartInfo.Verb = "OPEN" 'SET WHAT TO DO TO THE FILE
RunProgram.Start() 'RUN THE FILE
When that code runs, I get an, "An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in system.dll. Additional information: The system cannot find the file specified" error. An example of what listviewLocalFile.SelectedItems(0).Text contains would be C:\test.txt.