Solved

VB.net button file chooser

Posted on 2007-04-03
4
2,302 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Object Oriented Best Practice 5 33
String manipulation 15 49
Set form below another form 3 25
Getfiles in vb.net 21 12
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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…

708 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

15 Experts available now in Live!

Get 1:1 Help Now