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. }
Nathan Pakovskie is an esteemed senior developer and educator in the tech community, best known for his contributions to Geekpedia.com. With a passion for coding and a knack for simplifying complex tech concepts, Nathan has authored several popular tutorials on C# programming, ranging from basic operations to advanced coding techniques. His articles, often characterized by clarity and precision, serve as invaluable resources for both novice and experienced programmers. Beyond his technical expertise, Nathan is an advocate for continuous learning and enjoys exploring emerging technologies in AI and software development. When he’s not coding or writing, Nathan engages in mentoring upcoming developers, emphasizing the importance of both technical skills and creative problem-solving in the ever-evolving world of technology. Specialties: C# Programming, Technical Writing, Software Development, AI Technologies, Educational Outreach

Leave a Reply

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

Back To Top