Tuesday, February 12, 2008

DirectoryInfo class: Listing files in the specified directory - VB.Net, C#.Net

The DirectoryInfo class provides the basic functionality to access and manipulate a single directory in the file system.

Properties:
Parent
Root
Methods:
Create
CreateSubDirectory
GetDirectories
GetFiles
GetFileSystemInfo
MoveTo

Example: This exaple will list all files in the specified directory

DirectoryInfo myDir = new DirectoryInfo(@"H:\movies");

Console.WriteLine("Directory: {0}", myDir.FullName);

foreach (FileInfo myfile in myDir.GetFiles())
{
Console.WriteLine("File: {0}", myfile.Name);
}

1 comment:

Anonymous said...

Amiable brief and this fill someone in on helped me alot in my college assignement. Say thank you you seeking your information.

landscape paintings nature art landscape art sky art illustration art artwork art human art beautiful art landscape prints nature prints sky prints illustration prints artwork prints human prints beautiful prints beautiful special promotions nature special promotions sky special promotions illustration special promotions artwork special promotions beautiful canvas prints beautiful painting canvas prints beautiful framed prints beautiful painting framed prints beautiful posters beautiful painting posters