Solved

VB.net button file chooser

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

617 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