C# program to get the list of files from a given directory

C# program to get the list of files from given directory

Syntax:

string[] Directory.GetFiles(string path);

Program:

using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            string[] files;

            files =Directory.GetFiles("E:/pics/birthday-2014/");

            Console.WriteLine("File Names:");
            for (int i = 0; i < files.Length; i++)
            {
                Console.WriteLine("\t"+files[i]);
            }
        }
    }
}

Output:

File Names:
        E:/pics/birthday-2014/IMG_20140814_212013.jpg
        E:/pics/birthday-2014/IMG_20140814_212204.jpg
        E:/pics/birthday-2014/IMG_20140814_212211.jpg
        E:/pics/birthday-2014/IMG_20140814_212219.jpg
        E:/pics/birthday-2014/IMG_20140814_212225.jpg
        E:/pics/birthday-2014/IMG_20140814_212229.jpg
        E:/pics/birthday-2014/IMG_20140814_212232.jpg

Recent Posts

error: Alert: Content is protected!!