I\'m trying to find out how to programmatically (I\'m using C#) determine the name (or i.p.) of servers to which my workstation has current maps. In other words, at some po
Inspired by map network drive path in C# here's another simple method using Scripting objects:
private static IDictionary GetMappedNetworkDrives()
{
var rawDrives = new IWshRuntimeLibrary.IWshNetwork_Class()
.EnumNetworkDrives();
var result = new Dictionary(
rawDrives.length / 2);
for (int i = 0; i < rawDrives.length; i += 2)
{
result.Add(
new DriveInfo(rawDrives.Item(i)),
rawDrives.Item(i + 1));
}
return result;
}
See https://msdn.microsoft.com/en-us/library/t9zt39at(v=vs.84).aspx for details about the IWshNetwork_Class.