Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleSee if a directory exists in VB .NET
DescriptionThis example shows how to see if a directory exists in Visual Basic .NET.
Keywordsdirectory exists, directory, exists
CategoriesVB.NET, Files and Directories
 
The System.IO.Directory.Exists method returns True if a file exists.
 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
    e As System.EventArgs) Handles MyBase.Load
    Dim dir_name As String = Application.StartupPath
    If System.IO.Directory.Exists(dir_name) Then
        lblDir1.Text = dir_name & " exists"
    Else
        lblDir1.Text = dir_name & " does not exist"
    End If

    dir_name = dir_name.Substring(0, _
        dir_name.LastIndexOf("\")) & "\Missing"
    If System.IO.Directory.Exists(dir_name) Then
        lblDir2.Text = dir_name & " exists"
    Else
        lblDir2.Text = dir_name & " does not exist"
    End If
End Sub
 
There's lots more information about VB 2005 in my book Visual Basic 2005 Programmer's Reference.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated