- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 the drive
Set the drive for which you want to display the name −
DriveInfo info = new DriveInfo("C");
Now, to get the drive name, use the Name property −
info.Name
Here is the complete code with output −
Example
using System; using System.Linq; using System.IO; public class Demo { public static void Main() { DriveInfo info = new DriveInfo("C"); Console.WriteLine(“Drive: “+info.Name); } }
Output
The following is the output −
D:/
- Related Articles
- C# Program to get free space in a drive
- C# Program to get the name of root directory
- Get the drive format in C#
- C# program to get the file name in C#
- How to get complete drive information using C#?
- Name the petroleum product used to drive heavy vehicles.
- Name the product of petroleum that is used to drive heavy vehicles.
- C# Program to display the name of the directory
- How to get the name of the current executable in C#?
- Java Program to get the name of the parent directory of the file or directory
- Java Program to get name of parent directory
- C# Program to get the absolute value of the time
- C# Program to get the type of the specified Enumeration
- C# program to get the extension of a file in C#
- Program to find the initials of a name in C++

Advertisements