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());
            }
            Console.ReadLine();
        }

Output

Hard Drive Type

More C# Snippets

Last modified: May 11, 2019