The source code to get the logical drives of computer system using Environment class is given below. The given program is compiled and executed successfully.
using System;
class Sample
{
//Entry point of Program
static public void Main()
{
string[] logicalDrives;
logicalDrives = Environment.GetLogicalDrives();
Console.WriteLine("Logical Drives of computer:");
foreach (string drive in logicalDrives)
{
Console.WriteLine("\t" + drive);
}
}
}
Output:
Logical Drives of computer:
C:\
D:\
E:\
F:\
H:\
Press any key to continue . . .
Program:
The source code to get the logical drives of computer system using Environment class is given below. The given program is compiled and executed successfully.
Output: