C# DirectoryInfo GetDirectories()

Description

DirectoryInfo GetDirectories() Returns the subdirectories of the current directory.

Syntax

DirectoryInfo.GetDirectories() has the following syntax.


public DirectoryInfo[] GetDirectories()

Returns

DirectoryInfo.GetDirectories() method returns

Example

Returns the subdirectories of the current directory.


using System;//  ww  w. ja  va  2  s .  co  m
using System.IO;

public class GetDirectoriesTest 
{
    public static void Main() 
    {
        DirectoryInfo di = new DirectoryInfo("c:\\");

        DirectoryInfo[] diArr = di.GetDirectories();

        foreach (DirectoryInfo dri in diArr)
            Console.WriteLine(dri.Name);
    }
}

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