1.使用WINDOWS API
复制代码 代码如下:
///
/// 判断一个磁盘驱动器的类型
///
/// 包含了驱动器根目录路径的一个字串
///
[Dllimport("Kernel32.dll", EntryPoint = "GetDriveTypeA", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern long GetDriveType(string nDrive);
2.使用System.IO.DriveInfo
复制代码 代码如下:
DriveInfo driveInfo = new DriveInfo(Drive);
通过driveInfo.DriveType



