Export (0) Print
Expand All
Expand Minimize

My.Computer.FileSystem.DirectoryExists Method 

Returns a Boolean indicating whether the specified directory exists.


' Usage
Dim value As Boolean = My.Computer.FileSystem.DirectoryExists(directory)
' Declaration
Public Function DirectoryExists( _
   ByVal directory As String _
) As Boolean

Parameters

directory

String. Path of the directory. Required.

True if the directory exists; otherwise False.

This method throws no exceptions.

The call to DirectoryExists requires FileIOPermission.

The following table lists examples of tasks involving the My.Computer.FileSystem.DirectoryExists method.

To See

Determine if a directory exists

How to: Determine if a Directory Exists in Visual Basic

This example determines whether the directory C:\backup\logs exists and checks its properties.

If My.Computer.FileSystem.DirectoryExists("C:\backup\logs") Then
    Dim logInfo As System.IO.DirectoryInfo
    logInfo = My.Computer.FileSystem.GetDirectoryInfo _
    ("C:\backup\logs")
End If

Namespace: Microsoft.VisualBasic.MyServices

Class: FileSystemProxy (provides access to FileSystem)

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

Yes

Windows Service

Yes

Web Site

Yes

The following permission may be necessary:

Permission Description

FileIOPermission

Controls the ability to access files and folders. Associated enumeration: Unrestricted.

For more information, see Code Access Security and Requesting Permissions.

Community Additions

ADD
Show:
© 2014 Microsoft