 
  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
C# Program to get the name of root directory
Use the RootDirectory property to get the name of the root directory.
Firstly, use DriveInfo to set the drive for which you want the root directory −
DriveInfo dInfo = new DriveInfo("C"); Now, the RootDirectory gives you the result −
dInfo.RootDirectory
Example
Here is the complete code −
using System; using System.Linq; using System.IO; public class Demo {    public static void Main() {       DriveInfo dInfo = new DriveInfo("C");       Console.WriteLine("Root Directory: "+dInfo.RootDirectory);    } }  Output
The following is the output −
C:\
Advertisements
 