- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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
To Continue Learning Please Login
Login with Google