C# Directory Exists

Description

Directory Exists Determines whether the given path refers to an existing directory on disk.

Syntax

Directory.Exists has the following syntax.


public static bool Exists(
  string path
)

Parameters

Directory.Exists has the following parameters.

  • path - The path to test.

Returns

Directory.Exists method returns true if path refers to an existing directory; otherwise, false.

Example

The following example shows how to use Directory.Exists.


using System;/*  ww  w  .j a v a  2 s .co m*/
using System.IO;
using System.Collections;

public class MainClass 
{
    public static void Main(string[] args) 
    {
        Console.WriteLine(Directory.Exists("path"));
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter