Is there any class or API available in C# to get available network drives or last available drive for mapping? For example "Z:". Something like this:
string mappeddrive = MappDriveUtil.GetLastAvailableMappedDrive(); // utility class
Can I just scan the local and mapped drives to find out? How to scan all the local and mapped drives already in use if this is the way to find out?
-
This is one of those questions that doesn't have a great answer. You can certainly use DriveInfo.GetDrives to enumerate all of the currently available drives. From that you can infer what drives were not mapped.
The problem though is that you can only tell what drives were not mapped not are not mapped. In between the call to GetDrives() and the actually mapping of the drive, it's entirely possible for someother program to come along and map the drive you've chosen. Your solution must take this possibility into account or it will suffer from reliability problems in this area.
David.Chu.ca : That's true. Actually, what I am going to do is to unmap a specified drive before mapping to it, instead of finding the available one.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.