try this class..
''' <summary>
''' Specifies the class used for displaying dialog boxes on the screen.
''' </summary>
''' <remarks></remarks>
Public Class DBrowse
#Region "[ DBrowse ] Declarations"
''' <summary>
''' Used to store the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box.
''' </summary>
''' <remarks></remarks>
Private m_Filter As String = "Text File (*.txt)|*.txt"
''' <summary>
''' Used to store the initial directory displayed by the file dialog box.
''' </summary>
''' <remarks></remarks>
Private m_InitialDirectory As String = My.Computer.FileSystem.SpecialDirectories.Desktop
''' <summary>
''' Used to store the root folder where the browsing starts from.
''' </summary>
''' <remarks></remarks>
Private m_RootFolder As Environment.SpecialFolder = Environment.SpecialFolder.Desktop
#End Region
#Region "[ DBrowse ] Constructors"
''' <summary>
''' Initializes a new instance of the <b>DBrowse</b> class.
''' </summary>
''' <remarks></remarks>
Public Sub New()
'NOTHING TO DO:
End Sub
#End Region
#Region "[ DBrowse ] Properties"
''' <summary>
''' Gets or sets the current file name filter string, which determines the choices that appear in the "Save as file type" or "Files of type" box in the dialog box.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks>The following is an example of a filter string: "Text files (*.txt)|*.txt|All files (*.*)|*.*" <br></br><br></br>
''' You can add several filter patterns to a filter by separating the file types with semicolons, for example, "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*"</remarks>
Public Property Filter() As String
Get
Return m_Filter
End Get
Set(ByVal value As String)
m_Filter = value
End Set
End Property
''' <summary>
''' Gets or sets the initial directory displayed by the file dialog box.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks>The InitialDirectory property is typically set using one of the following sources: <br></br><br></br>
''' A path that was previously used in the program, perhaps retained from the last directory or file operation.<br></br>
''' A path read from a persistent source, such as an application setting, a Registry or a string resource in the application.<br></br>
''' Standard Windows system and user paths, such as Program Files, MyDocuments, MyMusic, and so on.<br></br>
''' A path related to the current application, such as its startup directory.
''' <br></br>Default is <i>My.Computer.FileSystem.SpecialDirectories.Desktop</i></remarks>
Public Property InitialDirectory() As String
Get
Return m_InitialDirectory
End Get
Set(ByVal value As String)
m_InitialDirectory = value
End Set
End Property
''' <summary>
''' Gets or sets the root folder where the browsing starts from.
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks>Only the specified folder and any subfolders that are beneath it will appear in the dialog box and be selectable.
''' <br></br>Default is <i>Environment.SpecialFolder.Desktop</i></remarks>
Public Property RootFolder() As Environment.SpecialFolder
Get
Return m_RootFolder
End Get
Set(ByVal value As Environment.SpecialFolder)
m_RootFolder = value
End Set
End Property
#End Region
#Region "[ DBrowse ] Methods"
''' <summary>
''' Call(s) to Prompts the user to select a folder using <b>FolderBrowserDialog</b>.
''' <example><i>instance</i>.BrowserFolder(Me.TextBox1)</example>
''' </summary>
''' <param name="_ObjTextBox">TextBox object to assign the path selected by the user. </param>
''' <param name="_Message">Descriptive text displayed above the tree view control in the dialog box. </param>
''' <returns>Sucess or not as Boolean</returns>
''' <remarks></remarks>
Public Function BrowserFolder(ByVal _ObjTextBox As TextBox, Optional ByVal _Message As String = "Select the Folder and click OK..!!") As Boolean
Dim _ObjFldrBrwsr As New FolderBrowserDialog
_ObjFldrBrwsr.RootFolder = m_RootFolder
_ObjFldrBrwsr.ShowNewFolderButton = False
_ObjFldrBrwsr.Description = _Message
_ObjFldrBrwsr.SelectedPath = Trim(_ObjTextBox.Text)
If (_ObjFldrBrwsr.ShowDialog(_ObjTextBox) = Windows.Forms.DialogResult.OK) Then
_ObjTextBox.Text = _ObjFldrBrwsr.SelectedPath
_ObjFldrBrwsr.Dispose()
Return True
Else
_ObjFldrBrwsr.Dispose()
Return False
End If
End Function
''' <summary>
''' Call(s) to Runs a common dialog box <b>OpenFileDialog</b>
''' <example><i>instance</i>.BrowseFile(Me.TextBox1)</example>
''' </summary>
''' <param name="_ObjTextBox">TextBox object to assign the FileName selected by the user. </param>
''' <param name="_Title">The file dialog box title.</param>
''' <returns>Sucess or not as Boolean</returns>
''' <remarks></remarks>
Public Function BrowseFile(ByVal _ObjTextBox As TextBox, Optional ByVal _Title As String = "Select Text File...") As Boolean
Dim _ObjFileBrowser As New System.Windows.Forms.OpenFileDialog
_ObjFileBrowser.CheckFileExists = True
_ObjFileBrowser.CheckPathExists = True
_ObjFileBrowser.InitialDirectory = m_InitialDirectory
_ObjFileBrowser.Title = _Title
_ObjFileBrowser.FilterIndex = 0
_ObjFileBrowser.Multiselect = False
_ObjFileBrowser.Filter = m_Filter
If (_ObjFileBrowser.ShowDialog(_ObjTextBox) = Windows.Forms.DialogResult.OK) Then
_ObjTextBox.Text = _ObjFileBrowser.FileName
Return True
Else
Return False
End If
End Function
''' <summary>
''' Call(s) to Runs a common dialog box <b>SaveFileDialog</b>
''' <example><i>instance</i>.BrowseFileSaveAs(Me.TextBox1)</example>
''' </summary>
''' <param name="_ObjTextBox">TextBox object to assign the FileName selected by the user. </param>
''' <param name="_Title">The file dialog box title.</param>
''' <returns>Sucess or not as Boolean</returns>
''' <remarks></remarks>
Public Function BrowseFileSaveAs(ByVal _ObjTextBox As TextBox, Optional ByVal _Title As String = "Save File As...") As Boolean
Dim _ObjFileSaveAs As New System.Windows.Forms.SaveFileDialog
_ObjFileSaveAs.CheckFileExists = False
_ObjFileSaveAs.CheckPathExists = True
_ObjFileSaveAs.InitialDirectory = m_InitialDirectory
_ObjFileSaveAs.Title = _Title
_ObjFileSaveAs.FilterIndex = 0
_ObjFileSaveAs.Filter = m_Filter
If (_ObjFileSaveAs.ShowDialog(_ObjTextBox) = Windows.Forms.DialogResult.OK) Then
_ObjTextBox.Text = _ObjFileSaveAs.FileName
Return True
Else
Return False
End If
End Function
#End Region
End Class