---
title: "OpenFileDialog Control in VB.Net"  
description: "A OpenFileDialog control is used to select a file. OpenFileDialog provide files to the user and retrieves the user's file selection back to the progra"  
author: "Pushpendra Singh"  
published: 2010-12-13  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/310/openfiledialog-control-in-vb-dot-net  
category: "vb.net"  
tags: ["vb.net"]  
reading_time: 1 minute  

---

# OpenFileDialog Control in VB.Net

A [OpenFileDialog](https://www.mindstick.com/forum/1564/use-openfiledialog-to-get-path-of-open-database-c-sharp) [control](https://yourviews.mindstick.com/view/83439/bipartisan-gun-control-bill-passed-in-us-after-decades) is used to [select](https://www.mindstick.com/forum/34066/use-select-operator-in-linq) a file. OpenFileDialog provide files to the user and retrieves the user's file [selection](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) back to the [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program)\

[Drag and drop](https://www.mindstick.com/forum/454/how-to-drag-and-drop-multiple-image-from-one-canvas-to-onther-canvas-in-html5) OpenFileDialog control from toolbox on the [window Form](https://www.mindstick.com/forum/527/how-to-pass-datagridview-s-cells-value-to-another-window-form).

![OpenFileDialog Control in VB.Net](https://www.mindstick.com/mindstickarticle/efa33125-fcae-432e-b77c-737c927796f4/images/55e46a14-c527-4ed6-9d64-2a592a2ebd04.png)

![OpenFileDialog Control in VB.Net](https://www.mindstick.com/mindstickarticle/efa33125-fcae-432e-b77c-737c927796f4/images/c8cb01d3-c5d7-4dc9-a3ca-bf3b9ac6bf4e.png)

Drag and drop PictureBox and a Button.

![OpenFileDialog Control in VB.Net](https://www.mindstick.com/mindstickarticle/efa33125-fcae-432e-b77c-737c927796f4/images/0865f885-4b8e-447f-b408-c8104bbd0d05.png)

## Code:

```
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click         ' OpenFileDialog will open         OpenFileDialog1.ShowDialog()         ' OpenFileDialog will open this directory         OpenFileDialog1.InitialDirectory =  "c:\Libraries\Pictures"         'selected Image will show in the pictureBox         PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)         ' Image.FromFile Method Creates an Image from the specified file.End Sub
```

**Run the project**

![OpenFileDialog Control in VB.Net](https://www.mindstick.com/mindstickarticle/efa33125-fcae-432e-b77c-737c927796f4/images/a095c5f1-b8d9-418c-a044-a135d53baff7.png)

When you click select [image button](https://www.mindstick.com/forum/1535/css-image-button) then file file [browser](https://www.mindstick.com/articles/323165/top-10-fastest-internet-browsers-in-the-world) window will open.

![OpenFileDialog Control in VB.Net](https://www.mindstick.com/mindstickarticle/efa33125-fcae-432e-b77c-737c927796f4/images/d33e7135-dbb7-4160-9752-74f8c149f9ba.png)

When you select file and click open then selected file will show in the PictureBox on the Form.

![OpenFileDialog Control in VB.Net](https://www.mindstick.com/mindstickarticle/efa33125-fcae-432e-b77c-737c927796f4/images/86fcb8ea-f713-4111-bbaf-f16f8d987ab7.png)

---

Original Source: https://www.mindstick.com/articles/310/openfiledialog-control-in-vb-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
