2008-09-29 12 views

답변

18

메소드 GetDrives()는 System.IO.DriveType의 열거에 대응하는 속성 DriveType을 갖는 DriveInfo를 클래스를 반환 드라이브 :

DriveInfo[] allDrives = DriveInfo.GetDrives(); 
    foreach (DriveInfo d in allDrives) 
    { 
     Console.WriteLine("Drive {0}, Type {1}", d.Name, d.DriveType); 
    } 
+0

FYI'DriveType'은 외장형 USB 하드 드라이브에 대해'DriveType.Fixed '를 반환합니다. –

4

DriveInfo.DriveType이 적합합니다.

DriveInfo[] allDrives = DriveInfo.GetDrives(); 

foreach (DriveInfo d in allDrives) 
{ 
    Console.WriteLine("Drive {0}", d.Name); 
    Console.WriteLine(" File type: {0}", d.DriveType); 
} 
3

System.IO.DriveInfo 클래스 및 DriveType 속성을 확인하십시오.

여기
public enum DriveType 
{ 
    Unknown,   // The type of drive is unknown. 
    NoRootDirectory, // The drive does not have a root directory. 
    Removable,  // The drive is a removable storage device, 
        // such as a floppy disk drive or a USB flash drive. 
    Fixed,   // The drive is a fixed disk. 
    Network,   // The drive is a network drive. 
    CDRom,   // The drive is an optical disc device, such as a CD 
        // or DVD-ROM. 
    Ram    // The drive is a RAM disk. 
} 

모두에 대한 정보를 표시 MSDN에서 약간 조정될 예이다

관련 문제