C# Directory GetLogicalDrives

Description

Directory GetLogicalDrives Retrieves the names of the logical drives on this computer in the form " :\".

Syntax

Directory.GetLogicalDrives has the following syntax.


public static string[] GetLogicalDrives()

Returns

Directory.GetLogicalDrives method returns

Example

The following example uses the GetLogicalDrives method.


//from  ww  w  .  j av  a 2 s.c  o m
using System;

class Class1 
{
    static void Main(string[] args) 
    {
       string[] drives = System.IO.Directory.GetLogicalDrives();

       foreach (string str in drives) 
       {
           System.Console.WriteLine(str);
       }
    }
}

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