Articles → .NET → Get the list of files in a folder using C#

Get the list of files in a folder using C#






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



Click to Enlarge


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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250