14-10-12, 05:06 PM
التعامل مع الفئة DriveInfo :
تتيح لك هذه الفئة استعراض ال Drivers في جهازك ومعرفة بعض المعلومات عنها ، هذا المثال مباشرة من كتاب Pro.CSharp 2008 :
C#:
vb.net:
تتيح لك هذه الفئة استعراض ال Drivers في جهازك ومعرفة بعض المعلومات عنها ، هذا المثال مباشرة من كتاب Pro.CSharp 2008 :
C#:
كود :
Console.WriteLine("***** Fun with DriveInfo *****\n");
// Get info regarding all drives.
DriveInfo[] myDrives = DriveInfo.GetDrives();
// Now print drive stats.
foreach(DriveInfo d in myDrives)
{
Console.WriteLine("Name: {0}", d.Name);
Console.WriteLine("Type: {0}", d.DriveType);
// Check to see whether the drive is mounted.
if (d.IsReady)
{
Console.WriteLine("Free space: {0}", d.TotalFreeSpace);
Console.WriteLine("Format: {0}", d.DriveFormat);
Console.WriteLine("Label: {0}", d.VolumeLabel);
Console.WriteLine();
}
}
Console.ReadLine();vb.net:
كود :
Console.WriteLine("***** Fun with DriveInfo *****" & Chr(10) & "")
' Get info regarding all drives.
Dim myDrives As DriveInfo() = DriveInfo.GetDrives()
' Now print drive stats.
For Each d As DriveInfo In myDrives
Console.WriteLine("Name: {0}", d.Name)
Console.WriteLine("Type: {0}", d.DriveType)
' Check to see whether the drive is mounted.
If d.IsReady Then
Console.WriteLine("Free space: {0}", d.TotalFreeSpace)
Console.WriteLine("Format: {0}", d.DriveFormat)
Console.WriteLine("Label: {0}", d.VolumeLabel)
Console.WriteLine()
End If
Next
Console.ReadLine()