hi, i am currently doing my school project that require me to have this browse button.
this browse button will open a dialog box and the user can open the file from there.
example if the user has a microsoft words doc file and they want to view it they just double-click it and the ms Word will be launch. ..

anybody have any suggestion in how to code it out....

thanks=D

hi Luc001
thanks for the reply, by the way
i cant open the link u given :(

anyway would you like to take a look at the code

Dim fdlg As New OpenFileDialog


        fdlg.Title = "C# Corner Open File Dialog"
        fdlg.InitialDirectory = "c:\"
        fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
        fdlg.FilterIndex = 2
        fdlg.RestoreDirectory = True
        If fdlg.ShowDialog() = DialogResult.OK Then
            'textBox1.Text = fdlg.FileName

            fdlg.OpenFile()
        End If

    End Sub

but i cant open the selected file

thank you so much:)

Edited 5 Years Ago by ~s.o.s~: Added code tags, please learn to use them.

Hi,

First the proper link, look here.

I think:

'textBox1.Text=fdlg.FileName

is a typo.

Try this:

Dim fdlg As New OpenFileDialog

fdlg.Title = "C# Corner Open File Dialog"
fdlg.InitialDirectory = "c:\"
        fdlg.Filter = "Word Documents (*.Doc)|*.Doc|txt files (*.txt)|*.txt|All files (*.*)|*.*"
fdlg.FilterIndex = 2
fdlg.RestoreDirectory = True
If fdlg.ShowDialog() = DialogResult.OK Then
TextBox1.Text = fdlg.FileName

fdlg.OpenFile()
End If
This article has been dead for over six months. Start a new discussion instead.