- 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 display the name of the directory
Firstly, use the DirectoryInfo that operates on Directories. The parameter set in it is the file path −
DirectoryInfo dir = new DirectoryInfo(@"D:
ew\");
To get the name of the directory, use the Name property −
dir.Name
The following is the code to display the name of the directory −
Example
using System.IO; using System; public class Program { public static void Main() { DirectoryInfo dir = new DirectoryInfo(@"D:
ew\"); // displaying the name of the directory Console.WriteLine(dir.Name); } }
Output
D:
ew\
Advertisements
To Continue Learning Please Login
Login with Google