Determine if a Directory Exists in Visual Basic
To determine if a directory exists
Use the My.Computer.FileSystem.DirectoryExists method, supplying the path, to determine whether or not the specified directory exists. The following example checks to determine whether or not the directory C:\backup\errorlogs exists and checks its properties.
Dim logDirectoryProperties As System.IO.DirectoryInfo
If My.Computer.FileSystem.DirectoryExists("C:\backup\errorlogs") Then
logDirectoryProperties = My.Computer.FileSystem.GetDirectoryInfo("C:\backup\errorlogs")
End If
To determine if a directory exists
Use the My.Computer.FileSystem.DirectoryExists method, supplying the path, to determine whether or not the specified directory exists. The following example checks to determine whether or not the directory C:\backup\errorlogs exists and checks its properties.
Dim logDirectoryProperties As System.IO.DirectoryInfo
If My.Computer.FileSystem.DirectoryExists("C:\backup\errorlogs") Then
logDirectoryProperties = My.Computer.FileSystem.GetDirectoryInfo("C:\backup\errorlogs")
End If
No comments:
Post a Comment