Articles → CSHARP → Get The List Of Files In A Folder Using C#

Get The List Of Files In A Folder Using C#






Folder




Picture showing the list of files in the particular folder
Click to Enlarge


Code


using System; 
using System.IO;
namespace GetAllFilesDemo {
    class Program {
        static void Main(string[] args) {
            string[] files = Directory.GetFiles(@ "c:\tmp");
            foreach(string file in files) {
                Console.WriteLine(Path.GetFileName(file));
            }
            Console.ReadLine();
        }
    }
}



Output


Picture showing the list of files from the folder fetched programmatically using C#
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Thursday, September 7, 2017

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250