Full filename from ListBox

Posted on 2004-11-12
Medium Priority
Last Modified: 2010-04-23
I have populated a list box of files from a directory.
Now when I select a from from that list box I want a message box to display the full path of the file.
Question by:sherrick123
LVL 24

Expert Comment

by:Jeff Certain
ID: 12566398
I'm assuming what you know what directory the files are in. If this is the case, you should be able to do this, assuming you are creating a desktop application:

msgbox(<directory name> & "\" & listbox1.SelectedItem)

The \ may or may not be needed, depending on how you're storing your directory name.

LVL 27

Accepted Solution

planocz earned 2000 total points
ID: 12566665
 sample code ....

Imports System.IO

 Private Sub CheckNameFile()
        ' Create a reference to the current directory.
        Dim di As New DirectoryInfo(listbox1.SelectedItem)
        ' Create an array representing the files in the current directory.
        Dim fi As FileInfo() = di.GetFiles()
        Dim fiTemp As FileInfo
        'Check for old files in directory
        For Each fiTemp In fi
            If fiTemp.Exists Then
              messagebox.show(  fiTemp.FullName)
            End If
        Next fiTemp
    End Sub

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Loops Section Overview
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question