Solved

VB.net button file chooser

Posted on 2007-04-03
4
2,308 Views
Last Modified: 2013-11-26
How do I make a vb.net button that will open a file browser and browse for a *.xml file for the user to select?
0
Comment
Question by:dprundle
  • 2
4 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 18846571
0
 

Author Comment

by:dprundle
ID: 18846647
I don't need to browse for a folder, I need to browse for an XML file.
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 18846858
Use the OpenFileDialog():
http://msdn2.microsoft.com/en-us/library/system.windows.forms.openfiledialog.aspx

Something like...

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ofd As New OpenFileDialog
        ofd.Title = "Please select an XML file"
        ofd.Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*"
        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim fi As New System.IO.FileInfo(ofd.FileName)

            ' do something with "fi"...
            Debug.Print(fi.Name)
            Debug.Print(fi.DirectoryName)
            Debug.Print(fi.FullName)

        End If
    End Sub
0
 

Author Comment

by:dprundle
ID: 18846999
idle_mind you are amazing. thanks again
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

896 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now