تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
الدرس التاسع والأربعون : System.IO
#5
التعامل مع الفئة DriveInfo :

تتيح لك هذه الفئة استعراض ال 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()
الرد }}}
تم الشكر بواسطة:


الردود في هذا الموضوع
الدرس التاسع والأربعون : System.IO - بواسطة oneyemenweb2_mybb_import4801 - 14-10-12, 05:06 PM


التنقل السريع :


يقوم بقرائة الموضوع: