- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Listing out directories and files using C#
The Directory class in C# has many methods to perform operations on directories and sub-directories −
|Sr.No||Method & Description|
Creates all directories and subdirectories in the specified path unless they already exist.
Creates all the directories in the specified path, unless the already exist, applying the specified Windows security.
Deletes an empty directory from a specified path.
Deletes the specified directory and, if indicated, any subdirectories and files in the directory.
Returns an enumerable collection of directory names in a specified path.
Returns an enumerable collection of directory names that match a search pattern in a specified path.
To get the directory names, use the EnumerateDirectories method. Our folder is set using DirectoryInfo class −
DirectoryInfo info = new DirectoryInfo(@"D:/new");
Now find the size −
long totalSize = info.EnumerateFiles().Sum(file => file.Length);
For the directories, use −
- Listing out directories and files in Python?
- Generate temporary files and directories using Python
- Listing modified, old and newly created files on Linux using C++
- How to list non-hidden files and directories in windows using Python?
- How to Protect Files and Directories from Deleting in Linux
- How to remove files and directories in the Linux operating system using the terminal?
- Find the Largest Top 10 Files and Directories On a Linux
- C Program to list all files and sub-directories in a directory
- How to move a file, group of files, and directories in Linux?
- How to compare the files available in two directories using diff command in Linux?
- How to Find a Specific String or Word in Files and Directories in Linux
- How to get all the directories and sub directories inside a path in C#?
- How to list out the hidden files in a Directory using Java program?
- Create, Delete and Change Directories in Perl
- Directories in Python