GetDriveType in C#? or find out if my drive is rem

2019-01-20 10:18发布

I am using Environment.GetLogicalDrives(); to get a list of drives. I remember in c++ i could use GetDriveType to find if the device was CD, removable, flash, etc and i am thinking i want to put a filter in my app to only show CD and removable on default. What is the GetDriveType equivalent in C#? google only showed me hacks to use the c++ call.

2条回答
Ridiculous、
2楼-- · 2019-01-20 10:52

Yes, the framework includes a DriveType enumeration used by the DriveInfo class. Have a look at the GetDrives() method on MSDN.

查看更多
对你真心纯属浪费
3楼-- · 2019-01-20 10:58

DriveInfo is the class you are looking for.

查看更多
登录 后发表回答