Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

OpenFileDialog

Posted on December 18, 2013October 26, 2015 By David Kittell

On a form create a textbox (txtFilePath), button (btnFilePathBrowse), and OpenFileDialog (ofdFilePath).

Double click on the button and the OpenFileDialog in Design view to create the action scripts

Private Sub btnFilePathBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFilePathBrowse.Click
		ofdFilePath.Title = "Please Select a File"
		ofdFilePath.FileName = ""
		ofdFilePath.InitialDirectory = "C:"
		ofdFilePath.ShowDialog()
End Sub

Private Sub ofdFilePath_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles ofdFilePath.FileOk
	Dim sioStream As System.IO.Stream
	sioStream = ofdFilePath.OpenFile()
	txtFilePath.Text = ofdFilePath.FileName.ToString()
End Sub
private void btnFilePathBrowse_Click(System.Object sender, System.EventArgs e)
{
	ofdFilePath.Title = "Please Select a File";
	ofdFilePath.FileName = "";
	ofdFilePath.InitialDirectory = "C:";
	ofdFilePath.ShowDialog();
}

private void ofdFilePath_FileOk(System.Object sender, System.ComponentModel.CancelEventArgs e)
{
	System.IO.Stream sioStream = null;
	sioStream = ofdFilePath.OpenFile();
	txtFilePath.Text = ofdFilePath.FileName.ToString();
}
Originally Posted on December 18, 2013
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code CSharp VB.NET

Post navigation

Previous post
Next post

Related Posts

MySQL Procedure Get WordPress Site Name

Posted on October 13, 2015October 13, 2015

If you manage many WordPress site databases it can get a bit crazy to know which site goes with what database but it gets more “fun” when you have a network site, below I attempt to help document some ways to help. This first example is a rather long process…

Read More

Proxy Switch

Posted on June 18, 2015October 26, 2015

Recently had a need to be able to switch on/off proxy at will and got tired of going to Internet Explorer options to set/change it. Hopefully someone else will get benefit from this nice tool. Open Visual Studio File -> New Project -> Visual C# – Windows -> Windows Forms…

Read More

Select Records Within Date Range

Posted on April 24, 2013October 26, 2015

This query include the start and end date. SELECT * FROM table WHERE datefield BETWEEN ‘<start date>’ AND ‘<end date>’ Originally Posted on April 24, 2013Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or program is…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • C# - Start/Stop/Restart Services
  • MacPorts / HomeBrew - Rip CD tracks from terminal
  • PowerShell - Show File Extensions
  • Open On Screen Keyboard (OSK)
  • SQLite - Auto-Increment / Auto Generate GUID
©2025 David Kittell | WordPress Theme by SuperbThemes