Get files from a directory – C#/C Sharp

Hi,

Sometimes you may need to get the files from a specified directory using C# / C Sharp. See the sample code on how it works.

using System;
using System.IO;

class MainClass
{
  public static void Main()
  {
    string[] yourFiles = Directory.GetFiles("c:");

    foreach (string fNames in yourFiles)

      Console.WriteLine(fNames);
  }

}

This code will get you files from the root directory.
:)