Syntax:
String [] Directory.GetDirectories(string path);
Program:
using System;
using System.IO;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
String []dirs = Directory.GetDirectories("D:/Sample");
Console.WriteLine("Sub directories are:");
for (int i = 0; i < dirs.Length; i++)
{
Console.WriteLine("\t"+dirs[i]);
}
}
}
}
Output:
Sub directories are:
D:/Sample\Blue Color
D:/Sample\Blue Whale
D:/Sample\Green color
D:/Sample\Green vegetable
D:/Sample\Red color