Question Problem with opening listbox item

NiTRoX.NET

Member
Joined
Dec 21, 2006
Messages
6
Programming Experience
Beginner
View attachment program.bmp

Hi Again guys,

Basically my problem is that I want an item from the listbox to open the file (containing the name) with the native application for the file extension when the 'Open' button is clicked.

Can anyone help me solve the problem.

With DirectoryInfo I know that you can get the full path by typing (for e.g.) lstInfo.SelectedItem.FullName

here is the code so far and an attached image to get a basic idea of the GUI:

VB.NET:
Imports System.IO
Imports System
Imports System.Text


Public Partial Class MainForm
	Public Sub New()
		
		Me.InitializeComponent()
		
	End Sub
	
	Sub Button1Click(sender As Object, e As EventArgs)

	Dim sDir As String = "Z:\MERGED"

	Dim dDir As New DirectoryInfo(sDir)
	Dim fFileSystemInfo As FileSystemInfo
	
 
		Dim currentTime As System.DateTime = System.DateTime.Now
	
	 lstInfo.Items.Clear
	
		
	
	For Each fFileSystemInfo In dDir.GetFileSystemInfos()
		
		lstInfo.Items.Add(fFileSystemInfo.Name)
		
		
		
	Next
	
	label5.Text = lstInfo.Items.Count	
	label1.Text = currentTime.Date 
	label4.Text = currentTime.TimeOfDay.ToString
	
		
	End Sub	
	
	
	
	
	Sub BtnSearchClick(sender As Object, e As EventArgs)
		
	
		
		Dim tempInt = lstInfo.Items.Count - 1
		
		While (tempInt > -1)
			
    If lstInfo.Items(tempInt).ToString.Contains(txtSearch.Text) = False Then
       lstInfo.Items.RemoveAt(tempInt)
    	
    End If
    
    tempInt -= 1
    
		End While
		

		
	End Sub
	
	
	
	
    End Class
 
Back
Top