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,

You can use the OpenfileDialog Class for that.
You can find some explanation and example, here.

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:)

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

hi Luc001.
thank you so much...
i will try it out

=D

Hi,

No problem, let me now if it works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.