C# Program to Get the Logical Drives of Computer System Using Environment Class
In C#, Environment Class provides information about the current platform and manipulates, the current platform. It is useful for getting and setting various operating system-related information. We can use it in such a way that it retrieves command-line arguments information, exit codes information, environment variable settings information, contents of the call stack information, and time since the last system boot in milliseconds information. In this article, we will get the logical drives of the computer system. So to solve this problem we use the GetLogicalDrives() method of the Environment Class. This method is used to get the logical drives present in your computer. It will return the array of drives in the string format.
Return: The return type of this method is an array of strings. And this array of strings holds the name of the logical drives present in the computer system.
Exception: This method also throws the following exceptions:
- IOException: GetLogicalDrives() method throws this exception when the Input/Output error occurs.
- SecurityException: GetLogicalDrives() method throws this exception when the caller does not have suitable permission.
Logical Drives of this computer: C:\ D:\ E:\ F:\
Please Login to comment...