Q:

C# program to get the logical drives of computer system using Environment class

belongs to collection: C# Environment Class Programs

0

Syntax:

string[] Environment.GetLogicalDrives();

Parameter(s):

This method does not accept any parameter.

Return value:

This method returns an array of strings that contains the name of logical drives of the computer system.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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.

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 . . .

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# Environment Class Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to get the environment variables using ... >>
<< C# program to demonstrate the use of FailFast() me...