Tuesday, February 12, 2008

DriveInfo - Listing Drives in C#.Net

Example:
DriveInfo[] mydrives = DriveInfo.GetDrives();

foreach (DriveInfo mydrive in mydrives)
{
Console.WriteLine("Drive: {0}", mydrive.Name);
Console.WriteLine("Type: {0}", mydrive.DriveType);
}

Note:
- GetDrives() is a static( shared in VB.Net) method.

- DriveType enumeration has the following values:
CDRom - An optical drive. It can be CD-ROM, DVD, and so on.
Fixed - A fixed disk.
Network - A network mapped drive.
NoRootDirectory - A drive that does not have a root directory.
Ram - A RAM drive.
Removable - A drive that has removable media.
Unknown - The drive could not be determined

1 comment:

Anonymous said...

Plz..., can you show sample, how i can work with drive type RAM?

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