In this example I will show you how to use GetLogicalDrives method of returns all logical drives on a system.
To do this, create a new Project and write the following code. The following example shows how to display the logical drives of the current computer using the GetLogicalDrives method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
class Program { static void Main(string[] args) { string[] drives = System.IO.Directory.GetLogicalDrives(); foreach (string drive in drives) { System.Console.WriteLine(drive); } Console.ReadLine(); } } |
Output: