问题
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