C#判断指定的驱动器是否已经准备好了的代码

198 阅读1分钟
把内容过程中经常用的内容备份一次,下边资料是关于C#判断指定的驱动器是否已经准备好了的内容,应该对小伙伴们有所用。 

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
 
class Program {
    static void Main(string[] args) {
        DriveInfo[] myDrives = DriveInfo.GetDrives();
 
        foreach (DriveInfo d in myDrives) {
            Console.WriteLine("Name: {0}", d.Name);
            Console.WriteLine("Type: {0}", d.DriveType);
 
            if (d.IsReady) {
                Console.WriteLine("Free space: {0}", d.TotalFreeSpace);
                Console.WriteLine("Format: {0}", d.DriveFormat);
                Console.WriteLine("Label: {0}n", d.VolumeLabel);
            }
        }
        Console.ReadLine();
    }
}