

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 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:\new\");
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:\new\"); // displaying the name of the directory Console.WriteLine(dir.Name); } }
Output
D:\new\
- Related Questions & Answers
- Java Program to get the name of the parent directory of the file or directory
- C# Program to get the name of root directory
- Java Program to get name of parent directory
- Java Program to get name of specified file or directory
- C# Program to display name of Current Thread
- How to display the name of the Current Thread in C#?
- How to display the current working directory in the Linux system?
- Java Program to get the content of a directory
- C# Program to get the name of the drive
- Display the package name of a class in Java
- Display the Operating System name in Java
- Display the current method name in Java
- How to stop the service with the display name in PowerShell?
- How to display the day name on the basis of Date of Birth records in MySQL?
- C# Program to display the Factors of the Entered Number
Advertisements