DirectoryInfo class is useful for creating, moving, and enumerating through directories and subdirectories.
for example, you can make a new directory like this,
DirectoryInfo di = new DirectoryInfo(@”c:\TestDir”);
FileInfo class provides instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of FileStream objects.
Here is a simple code snippet to list all files in a given directory (example takes a directory path as input and returns an array list of files)
private ArrayList GetFileList(string inputDir)
ArrayList fileList = new ArrayList();
DirectoryInfo di = new DirectoryInfo(inputDir);
//GetFiles method accepts filter patterns like “*.xml”
FileInfo fArray = di.GetFiles(“*.*”);foreach(FileInfo fi in fArray)