Hi friends, In this tutorial We are going to learn DirectoryInfo class in C#. DirectoryInfo class in c# enables you to work with Directory. With Directory Info class You can create, delete, Move or enumerate a directory.
What is DirectoryInfo class in c#?
DirectoryInfo class in c# enables you to work with Directory. With Directory Info class You can create, delete, Move or enumerate a directory. You can also get info about any directory like creation time, last access time of a directory using the Directory info class.
The DirectoryInfo class accepts a single parameter that is either the full path or relative path of the directory.
where,, dirname is the name of your directory.
Some of the Important properties of the DirectoryInfo class are:
CreationTime: It is used to retrieve the creation time of the directory.
LastAccessTime: It is used to retrieve the last access time of the directory.
FullName: It is used to retrieve the fully qualified path of the directory.
Name: It is used to retrieve only the name of the folder without the path. For example, If your directory exists at D:\MyDoc\MyDir then this property will only return folder name i.e. MyDir.
Create Directory Example:
Move Directory Example:
Delete Directory Example:
Get /Directory Details Example:
- Sealed class in C#
- Difference between Constant and Readonly in C#.
- static constructor in C#.
- Index out of range exception in C#.
I hope this is a useful post for you. Please don’t hesitate to comment for any technical issues. Your feedback and comments are usefull for me.