Solved

VB.net button file chooser

Posted on 2007-04-03
4
2,319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 86

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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

728 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