Retrieve a list of disk drives using C#

Retrieve a list of disk drives using C#
This code retrieves a list of drives, stores it into an array of strings, and then loops through it to display the drives.
1. // Store the list of drives into an array of string
2. string[] DriveList = Environment.GetLogicalDrives();
3. // Loop through the array
4. for (int i = 0; i < DriveList.Length; i++)
5. {
6.     // Show each drive
7.     MessageBox.Show(DriveList[i]);
8. }

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top