Network Drive label

自古美人都是妖i 提交于 2019-12-12 02:34:59

问题


I'm trying to get the label of some network resources mapped as drives. When I use DriveInfo.GetDrives(), local volumes have the VolumeLabel filled parameter as expected, but in network drives it is an empty string. How can I get those labels?


回答1:


You can use WMI for this - not sure of the exact query (it's been a while), but here's an example of how to get network drive free space:

http://en.csharp-online.net/Network_Drive_Free_Space

I think replacing 'name' with 'VolumeName' in that example will give you what you need.

WMI reference here just in case:

http://msdn.microsoft.com/en-us/library/aa394173(VS.85).aspx




回答2:


Never use WMI Use net apis.



来源:https://stackoverflow.com/questions/343346/network-drive-label

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