List Files in a folder

A user in the MSDN forums asked the following question in the following thread:

Hello, I am very new to programming and would like some help. I need a program that will search in a supplied folder and list all PDF type of file in a text box, and then have the operator select the file to open.

Can someone show me the code to do this?

Here is how I would.

    ''' <summary>
    ''' Returns the path to a pdf file that the user selected. Returns a blank if the user cancelled.
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function OpenPDF() As String
        Dim OFD As New OpenFileDialog
        OFD.Filter = "Pdf Files|*.pdf"
        If OFD.ShowDialog = DialogResult.OK Then
            Return OFD.FileName
        End If
        Return ""
    End Function
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s