[C#] How to Get Files in a Directory in C#

Hello friends !

Now, we will learn How to Get Files in a Directory in C#.  

The GetFiles method gets a list of files in the specified directory. To get file names from the specified directory, use static method Directory.Get­Files. Lets have these files and subfolders in “C:\Temp” folder.

This example shows how to get list of file names from a directory (including subdirectories). You can filter the list by specific extension.

string root = @"C:\Temp";
string[] fileEntries = Directory.GetFiles(root);
foreach (string fileName in fileEntries) 

I wish you success, please leave a comment below, we will answer all your questions.

GoodLuck !!!




Xem thêm  [C#] How to Get Sub Directories in C#

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *