Monday, September 25, 2017

Get all files in directory C#

class Program
{
    static void Main()
    {
        // Get list of files in the specific directory.
        // ... Please change the first argument.
        string[] files = Directory.GetFiles("C:\\myDir\\",
            "*.*",          SearchOption.AllDirectories);

        // Display all the files.
        foreach (string file in files)
        {
            Console.WriteLine(file);
        }
    }
}

No comments:

Post a Comment