 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
GetLogicalDrives in C#
To get all the disk drives on a system, use the GetLogicalDrives() method in C# −
Environment.GetLogicalDrives()
Use it with Join method to get the comma-separated list of logical drives −
string.Join(",", Environment.GetLogicalDrives())
Example
using System;
using System.IO;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         Console.WriteLine(string.Join(",", Environment.GetLogicalDrives()));
      }
   }
}
Output
/,/etc/resolv.conf,/etc/hostname,/etc/hosts,/run/secrets,/home/cg/root
Advertisements
                    