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

廉价感情. 提交于 2019-12-17 21:04:13

问题


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.


回答1:


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




回答2:


DriveInfo is the class you are looking for.



来源:https://stackoverflow.com/questions/623254/getdrivetype-in-c-or-find-out-if-my-drive-is-removable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!