How to Set Get List of all the logical drives on a System

The following code example determines How to get all logical drives of a system and prints that.

Step 1:-Add the following namespaces

using System;
using System.IO;

Step 2:-Initilizes variables

string[] drives = System.IO.Directory.GetLogicalDrives();

Step 3:-Print all the logical drives

foreach (string str in drives)

Special Note:- Directory class is static and all methods can be called without creating any instance of this class


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: