Get Hard Drive Type using C#

The snippet below will get you the drive type where a specified file/folder is.

        static void Main(string[] args)
            System.IO.FileInfo file = new System.IO.FileInfo("M:\"); // 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());


Hard Drive Type

More C# Snippets

Tutorials Panel

About Tutorials Panel

programming tutorial and source code for Software Engineers and developers.

View all posts by Tutorials Panel →