C# Program to Get the List of Files From Given Directory Last Updated : 01 Feb, 2022 Comments Improve Suggest changes Like Article Like Report Given a directory, now we will find the list of files from the given directory. So for this, we use the GetFiles() method of the Directory class. This method is used to find the list of files from the given directory or sub directories. The overloaded methods of this method are: 1. GetFiles(String): This method will return the names of files (including their paths) in the specified directory. Syntax: public static string[] GetFiles (string path); 2. GetFiles(String, String): This method will return the names of files (including their paths) that match the specified search pattern in the specified directory. Syntax: public static string[] GetFiles (string path, string searchPattern); 3. GetFiles(String, String, SearchOption): This method will return the names of files (including their paths) that match the specified search pattern and enumeration options in the specified directory. Syntax: public static string[] GetFiles (string path, string searchPattern, System.IO.EnumerationOptions enumerationOptions); 4. GetFiles(String, String, SearchOption): This method will return the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories. Syntax: public static string[] GetFiles (string path, string searchPattern, System.IO.SearchOption searchOption); Example: In this example, we are going to find the files present in the C drive using the GetFiles() method. C# // C# program to get the list of // files from the specified directory using System; using System.IO; class GFG{ static void Main() { // Getting files from C drive // Using the GetFiles() method string[] filedata = Directory.GetFiles(@"C:\"); // Displaying the file name one by one foreach (string i in filedata) { Console.WriteLine(i); } } } Output: A Dell flask web application Comment More infoAdvertise with us Next Article C# Program to Get the List of Files From Given Directory sravankumar_171fa07058 Follow Improve Article Tags : C# C# Programs Similar Reads C# Program to Get the List of Sub-Directories of a Given Directory Given a director, now we will find the list of the sub-directories present in the given directory. So to this task, we use the GetDirectories() method of the Directory class. This method is used to get the list of directories/sub-directories from the given directory or sub-directories. We have to sp 2 min read C# Program to Get Root Directory of Given Directory Directory class provides different types of methods for creating, moving, deleting, renaming, and modifying directories and subdirectories. GetDirectoryRoot() is a method of Directory class. This method is used to find the information of the volume or root or both for the given path. Or we can say t 2 min read C# Program to Get Computer Drive Names of Given Directory Directory class provides different types of methods for creating, moving, deleting, renaming, and modifying directories and subdirectories. GetLogicalDrives() is the method of the Directory class. This method is used to find the name of the logical drive names present in the computer. Or we can say 2 min read C# Program to Get Extension of a Given File DirectoryInfo class provides different types of methods and properties that are used to perform operations on directories and sub-directories like creating, moving, etc. This class has an Extension property which is used to find the extension part from the given file name which includes the dot form 2 min read C# Program to Search Sub-Directory in a Given Directory C# is a general-purpose,  object-oriented programming language pronounced as âC Sharpâ. It is a lot syntactically similar to Java and is easy for users who have knowledge of C, C++, or Java. In this article, we will learn How can we use C# to search the sub-Directory in a given Directory. So for  t 3 min read C# Program to Get Complete Path of Current Directory Given a directory, now our task is to find the path of the given directory or current directory. So to this task, we use the GetCurrentDirectory() method of the Directory class. This method will return the complete path of the current directory. The result given by this method will not end with a ba 1 min read C# Program to Demonstrate the Use of FullName Property DirectoryInfo class provides different types of methods and properties that are used to perform operations on directories and sub-directories like creating, moving, etc and FullName property is one of them. This property is used to find the full path of the directory or the specified file. Syntax: p 1 min read C# Program to Create a Directory A directory is a file system that stores file. Now our task is to create a directory in C#. We can create a directory by using the CreateDirectory() method of the Directory class. This method is used to create directories and subdirectories in a specified path. If the specified directory exists or t 2 min read C++ Program to Get the List of Files in a Directory Getting the list of files in a directory is one of the most common operations performed by the Filesystem of an OS. The file explorer application in most operating systems performs the same operation in the background. In this article, you will learn how to get the list of files in a directory using 4 min read C# Program For Listing the Files in a Directory Given files, now our task is to list all these files in the directory using C#. So to do this task we use the following function and class: DirectoryInfo: It is a class that provides different types of methods for moving, creating, and enumerating through directories and their subdirectories. You ca 2 min read Like