<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2FGUI%2FOpenFileDialog</id>
		<title>VB.Net Tutorial/GUI/OpenFileDialog - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2FGUI%2FOpenFileDialog"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/GUI/OpenFileDialog&amp;action=history"/>
		<updated>2026-04-05T07:41:36Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/GUI/OpenFileDialog&amp;diff=3884&amp;oldid=prev</id>
		<title> в 16:40, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/GUI/OpenFileDialog&amp;diff=3884&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:30Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 16:40, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/GUI/OpenFileDialog&amp;diff=3885&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/GUI/OpenFileDialog&amp;diff=3885&amp;oldid=prev"/>
				<updated>2010-05-26T12:57:21Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==File Open/Save dialog==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.Drawing.Drawing2D&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
public class FileSaveOpenDialog&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Application.Run(New Form1)&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        MyBase.New()&lt;br /&gt;
        InitializeComponent()&lt;br /&gt;
    End Sub&lt;br /&gt;
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
        If disposing Then&lt;br /&gt;
            If Not (components Is Nothing) Then&lt;br /&gt;
                components.Dispose()&lt;br /&gt;
            End If&lt;br /&gt;
        End If&lt;br /&gt;
        MyBase.Dispose(disposing)&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private components As System.ruponentModel.IContainer&lt;br /&gt;
    Friend WithEvents Button1 As System.Windows.Forms.Button&lt;br /&gt;
    Friend WithEvents Button2 As System.Windows.Forms.Button&lt;br /&gt;
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog&lt;br /&gt;
    Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; Private Sub InitializeComponent()&lt;br /&gt;
        Me.Button1 = New System.Windows.Forms.Button&lt;br /&gt;
        Me.Button2 = New System.Windows.Forms.Button&lt;br /&gt;
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog&lt;br /&gt;
        Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog&lt;br /&gt;
        Me.SuspendLayout()&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Button1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Button1.Location = New System.Drawing.Point(32, 32)&lt;br /&gt;
        Me.Button1.Name = &amp;quot;Button1&amp;quot;&lt;br /&gt;
        Me.Button1.Size = New System.Drawing.Size(88, 32)&lt;br /&gt;
        Me.Button1.TabIndex = 0&lt;br /&gt;
        Me.Button1.Text = &amp;quot;Open&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Button2&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Button2.Location = New System.Drawing.Point(160, 32)&lt;br /&gt;
        Me.Button2.Name = &amp;quot;Button2&amp;quot;&lt;br /&gt;
        Me.Button2.Size = New System.Drawing.Size(88, 32)&lt;br /&gt;
        Me.Button2.TabIndex = 1&lt;br /&gt;
        Me.Button2.Text = &amp;quot;Save&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Form1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)&lt;br /&gt;
        Me.ClientSize = New System.Drawing.Size(292, 110)&lt;br /&gt;
        Me.Controls.Add(Me.Button2)&lt;br /&gt;
        Me.Controls.Add(Me.Button1)&lt;br /&gt;
        Me.ResumeLayout(False)&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br /&gt;
        OpenFileDialog1.ShowDialog()&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click&lt;br /&gt;
        SaveFileDialog1.ShowDialog()&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Get selected file name in a OpenFileDialog==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.Drawing&lt;br /&gt;
Imports System.Drawing.Drawing2D&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
public class OpenFileDialogSelectedFileName&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Dim FileDB As New OpenFileDialog()&lt;br /&gt;
        If (FileDB.ShowDialog() = DialogResult.OK) Then&lt;br /&gt;
            Console.WriteLine(&amp;quot;File: &amp;quot; &amp;amp; FileDB.FileName)&lt;br /&gt;
        Else&lt;br /&gt;
            Console.WriteLine(&amp;quot;User selected Cancel&amp;quot;)&lt;br /&gt;
        End If&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Open File Dialog Filter==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.Drawing&lt;br /&gt;
Imports System.Drawing.Drawing2D&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
public class PictureBoxImageFromOpenFileDialog&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Application.Run(New Form1)&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        MyBase.New()&lt;br /&gt;
        InitializeComponent()&lt;br /&gt;
    End Sub&lt;br /&gt;
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
        If disposing Then&lt;br /&gt;
            If Not (components Is Nothing) Then&lt;br /&gt;
                components.Dispose()&lt;br /&gt;
            End If&lt;br /&gt;
        End If&lt;br /&gt;
        MyBase.Dispose(disposing)&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private components As System.ruponentModel.IContainer&lt;br /&gt;
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox&lt;br /&gt;
    Friend WithEvents Button1 As System.Windows.Forms.Button&lt;br /&gt;
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; Private Sub InitializeComponent()&lt;br /&gt;
        Me.PictureBox1 = New System.Windows.Forms.PictureBox&lt;br /&gt;
        Me.Button1 = New System.Windows.Forms.Button&lt;br /&gt;
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog&lt;br /&gt;
        Me.SuspendLayout()&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;PictureBox1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.PictureBox1.Location = New System.Drawing.Point(16, 16)&lt;br /&gt;
        Me.PictureBox1.Name = &amp;quot;PictureBox1&amp;quot;&lt;br /&gt;
        Me.PictureBox1.Size = New System.Drawing.Size(248, 176)&lt;br /&gt;
        Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize&lt;br /&gt;
        Me.PictureBox1.TabIndex = 0&lt;br /&gt;
        Me.PictureBox1.TabStop = False&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Button1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Button1.Location = New System.Drawing.Point(96, 208)&lt;br /&gt;
        Me.Button1.Name = &amp;quot;Button1&amp;quot;&lt;br /&gt;
        Me.Button1.Size = New System.Drawing.Size(88, 24)&lt;br /&gt;
        Me.Button1.TabIndex = 1&lt;br /&gt;
        Me.Button1.Text = &amp;quot;Open&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;OpenFileDialog1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.OpenFileDialog1.Filter = &amp;quot;bmp(*.bmp)|*.bmp&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Form1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)&lt;br /&gt;
        Me.ClientSize = New System.Drawing.Size(292, 266)&lt;br /&gt;
        Me.Controls.Add(Me.Button1)&lt;br /&gt;
        Me.Controls.Add(Me.PictureBox1)&lt;br /&gt;
        Me.ResumeLayout(False)&lt;br /&gt;
    End Sub&lt;br /&gt;
    &lt;br /&gt;
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br /&gt;
        Dim pic As Image&lt;br /&gt;
        OpenFileDialog1.ShowDialog()&lt;br /&gt;
        pic = New Bitmap(OpenFileDialog1.FileName)&lt;br /&gt;
        PictureBox1.Image = pic&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Prevent dialog box from validating file==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.IO&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
Module Module1&lt;br /&gt;
    Sub Main()&lt;br /&gt;
        Dim FileDB As New OpenFileDialog()&lt;br /&gt;
        FileDB.Filter = &amp;quot;All files | *.* | Text files | *.txt&amp;quot;&lt;br /&gt;
        FileDB.FilterIndex = 2&lt;br /&gt;
        FileDB.InitialDirectory = &amp;quot;C:\Temp&amp;quot;&lt;br /&gt;
        FileDB.AddExtension = True&lt;br /&gt;
        FileDB.DefaultExt = &amp;quot;txt&amp;quot;&lt;br /&gt;
        &amp;quot; Prevent dialog box from validating file&lt;br /&gt;
        FileDB.CheckFileExists = False&lt;br /&gt;
        FileDB.CheckPathExists = False&lt;br /&gt;
        If (FileDB.ShowDialog() = DialogResult.OK) Then&lt;br /&gt;
            Dim SourceFile As StreamReader&lt;br /&gt;
            Try&lt;br /&gt;
                SourceFile = New StreamReader(FileDB.FileName)&lt;br /&gt;
                Console.WriteLine(SourceFile.ReadToEnd())&lt;br /&gt;
                SourceFile.Close()&lt;br /&gt;
            Catch Except As Exception&lt;br /&gt;
                Console.WriteLine(&amp;quot;Error: &amp;quot; &amp;amp; Except.Message)&lt;br /&gt;
            End Try&lt;br /&gt;
        Else&lt;br /&gt;
            Console.WriteLine(&amp;quot;User selected Cancel&amp;quot;)&lt;br /&gt;
        End If&lt;br /&gt;
    End Sub&lt;br /&gt;
End Module&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Set InitialDirectory and FilterIndex for OpenFileDialog==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.Drawing&lt;br /&gt;
Imports System.Drawing.Drawing2D&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
public class OpenFileDialogInitDirectory&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Dim FileDB As New OpenFileDialog()&lt;br /&gt;
        FileDB.Filter = &amp;quot;All files | *.* | Word files | *.doc | Text files | *.txt&amp;quot;&lt;br /&gt;
        FileDB.FilterIndex = 3&lt;br /&gt;
        FileDB.InitialDirectory = &amp;quot;C:\Temp&amp;quot;&lt;br /&gt;
        If (FileDB.ShowDialog() = DialogResult.OK) Then&lt;br /&gt;
            Console.WriteLine(&amp;quot;File: &amp;quot; &amp;amp; FileDB.FileName)&lt;br /&gt;
        Else&lt;br /&gt;
            Console.WriteLine(&amp;quot;User selected Cancel&amp;quot;)&lt;br /&gt;
        End If&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Set OpenFileDialog Filter and get selected file name==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.Windows.Forms&lt;br /&gt;
public class FileOpenDialogFilter&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Dim openFileDialog1 As System.Windows.Forms.OpenFileDialog&lt;br /&gt;
        openFileDialog1 = New System.Windows.Forms.OpenFileDialog()&lt;br /&gt;
        &lt;br /&gt;
        openFileDialog1.Filter = &amp;quot;Word (*.doc) |*.doc;*.rtf|(*.txt) |*.txt|(*.*) |*.*&amp;quot;&lt;br /&gt;
        If openFileDialog1.ShowDialog() = DialogResult.OK Then&lt;br /&gt;
            Console.WriteLine(openFileDialog1.FileName)&lt;br /&gt;
        End If&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use OpenFileDialog to load image to PictureBox==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.Drawing&lt;br /&gt;
Imports System.Drawing.Drawing2D&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
public class OpenFileDialogPicture&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Application.Run(New Form1)&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
#Region &amp;quot; Windows Form Designer generated code &amp;quot;&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        MyBase.New()&lt;br /&gt;
        &amp;quot;This call is required by the Windows Form Designer.&lt;br /&gt;
        InitializeComponent()&lt;br /&gt;
        &amp;quot;Add any initialization after the InitializeComponent() call&lt;br /&gt;
    End Sub&lt;br /&gt;
    &amp;quot;Form overrides dispose to clean up the component list.&lt;br /&gt;
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
        If disposing Then&lt;br /&gt;
            If Not (components Is Nothing) Then&lt;br /&gt;
                components.Dispose()&lt;br /&gt;
            End If&lt;br /&gt;
        End If&lt;br /&gt;
        MyBase.Dispose(disposing)&lt;br /&gt;
    End Sub&lt;br /&gt;
    &amp;quot;Required by the Windows Form Designer&lt;br /&gt;
    Private components As System.ruponentModel.IContainer&lt;br /&gt;
    &amp;quot;NOTE: The following procedure is required by the Windows Form Designer&lt;br /&gt;
    &amp;quot;It can be modified using the Windows Form Designer.  &lt;br /&gt;
    &amp;quot;Do not modify it using the code editor.&lt;br /&gt;
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog&lt;br /&gt;
    Friend WithEvents Button1 As System.Windows.Forms.Button&lt;br /&gt;
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; Private Sub InitializeComponent()&lt;br /&gt;
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog&lt;br /&gt;
        Me.Button1 = New System.Windows.Forms.Button&lt;br /&gt;
        Me.PictureBox1 = New System.Windows.Forms.PictureBox&lt;br /&gt;
        Me.SuspendLayout()&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;OpenFileDialog1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.OpenFileDialog1.Filter = &amp;quot;JPEG files (*.jpg)|*.jpg|GIF files (*.gif)|*.gif|All files (*.*)|*.*&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Button1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.Button1.Location = New System.Drawing.Point(96, 88)&lt;br /&gt;
        Me.Button1.Name = &amp;quot;Button1&amp;quot;&lt;br /&gt;
        Me.Button1.Size = New System.Drawing.Size(88, 23)&lt;br /&gt;
        Me.Button1.TabIndex = 0&lt;br /&gt;
        Me.Button1.Text = &amp;quot;Show Dialog&amp;quot;&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;PictureBox1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.PictureBox1.Location = New System.Drawing.Point(88, 144)&lt;br /&gt;
        Me.PictureBox1.Name = &amp;quot;PictureBox1&amp;quot;&lt;br /&gt;
        Me.PictureBox1.Size = New System.Drawing.Size(104, 88)&lt;br /&gt;
        Me.PictureBox1.TabIndex = 1&lt;br /&gt;
        Me.PictureBox1.TabStop = False&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Form1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)&lt;br /&gt;
        Me.ClientSize = New System.Drawing.Size(292, 273)&lt;br /&gt;
        Me.Controls.Add(Me.PictureBox1)&lt;br /&gt;
        Me.Controls.Add(Me.Button1)&lt;br /&gt;
        Me.Name = &amp;quot;Form1&amp;quot;&lt;br /&gt;
        Me.Text = &amp;quot;Form1&amp;quot;&lt;br /&gt;
        Me.ResumeLayout(False)&lt;br /&gt;
    End Sub&lt;br /&gt;
#End Region&lt;br /&gt;
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click&lt;br /&gt;
        If OpenFileDialog1.ShowDialog() = DialogResult.OK Then&lt;br /&gt;
            PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)&lt;br /&gt;
        End If&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ruponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>