C# DriveInfo RootDirectory

Description

DriveInfo RootDirectory Gets the root directory of a drive.

Syntax

DriveInfo.RootDirectory has the following syntax.


public DirectoryInfo RootDirectory { get; }

Example

Gets the root directory of a drive.


using System;/*  w w w.  j av  a 2s.  com*/
using System.IO;

class Test
{
    public static void Main()
    {
        DriveInfo[] allDrives = DriveInfo.GetDrives();

        foreach (DriveInfo d in allDrives)
        {
            Console.WriteLine( d.RootDirectory);
        }
    }
}

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