Get files from a directory – C#/C Sharp

By | April 25, 2011


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)



This code will get you files from the root directory.


One thought on “Get files from a directory – C#/C Sharp

Leave a Reply to Doggy Cancel reply

Your email address will not be published.