In this example, we’ll learn how to get HDD type using C#.
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 | static void Main(string[] args) { System.IO.FileInfo file = new System.IO.FileInfo("E:\"); // File or Directory System.IO.DriveInfo _driveInfo = new System.IO.DriveInfo(file.FullName); Console.WriteLine("Drive: " + _driveInfo.Name); if (_driveInfo.IsReady) { Console.WriteLine("The drive type is: " + _driveInfo.DriveType.ToString()); } Console.ReadLine(); } |
Output:
