■ 논리적 드라이브 타입을 구하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
using System; using System.Runtime.InteropServices; ... /// <summary> /// 드라이브 타입 /// </summary> public enum DriveType { /// <summary> /// DRIVE_UNKNOWN /// </summary> Unknown = 0, /// <summary> /// DRIVE_NO_ROOT_DIR /// </summary> NoRootDirectory = 1, /// <summary> /// DRIVE_REMOVABLE /// </summary> Removable = 2, /// <summary> /// DRIVE_FIXED /// </summary> Fixed = 3, /// <summary> /// DRIVE_REMOTE /// </summary> Remote = 4, /// <summary> /// DRIVE_CDROM /// </summary> CDROM = 5, /// <summary> /// DRIVE_RAMDISK /// </summary> RAMDisk = 6 } ... #region 논리적 드라이브 타입 구하기 - GetDriveType(rootPath) /// <summary> /// 논리적 드라이브 타입 구하기 /// </summary> /// <param name="rootPath">루트 경로</param> /// <returns>드라이브 타입</returns> [DllImport("kernel32")] public static extern DriveType GetDriveType(string rootPath); #endregion ... DriveType driveType = GetDriveType("C:\\"); Console.WriteLine("Drive {0} is type {1}", "C:\\", driveType); |