FileSystem.DirectoryExists(String) メソッド

定義

指定したディレクトリが存在する場合は、 True を返します。

public:
 static bool DirectoryExists(System::String ^ directory);
public static bool DirectoryExists(string directory);
static member DirectoryExists : string -> bool
Public Shared Function DirectoryExists (directory As String) As Boolean

パラメーター

directory
String

ディレクトリのパス。

返品

True ディレクトリが存在する場合。それ以外の場合は False。 このメソッドは、パラメーターがディレクトリではなくファイルの名前とパスを表す場合も、 False を返します。

この例では、ディレクトリ C:\backup\logs が存在するかどうかを判断し、そのプロパティを確認します。

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

適用対象