Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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 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:/
Advertisements