Monday, December 8, 2008

Get the file name form the directroy

using System;
using System.IO;

public class GetFilesTest {
public static void Main() {

// make a reference to a directory
DirectoryInfo di = new DirectoryInfo("c:\\");

// get a reference to each file in that directory
FileInfo[] fiArr = di.GetFiles();

// print out the names of the files
foreach (FileInfo fri in fiArr)
Console.WriteLine(fri.Name);
}
}

No comments: