Click here to Skip to main content
15,917,628 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am writing an windows form application in C# for mapping the network drive.
The functionality of the application is as follow.
1.Check whether the Hardcoded network drive is already mapped
If mapped Ask users whether it need to be connected or not
else
Ask users whether it need to be Disconnected or not

Can some one help me how to check whether a network drive is connected for the perticular userid or not.


Thanks
Prashant P
Posted
Comments
vijay__p 8-May-13 9:19am    
Check below link whether it helps you or not
http://www.codeproject.com/Articles/90143/Mapping-Network-Drive-using-C
Prashant Bangaluru 8-May-13 9:35am    
Sorry the mentioned link is comparing with the network drive letters, What i need is it should check with paths like '//xyz/abs' ..not with the drive letters like 'A:\'.
CHill60 8-May-13 10:16am    
Er ... then that's not a "mapped network drive" it's just a path ... which doesn't really have a concept of connecting/disconnecting
Prashant Bangaluru 8-May-13 22:48pm    
I am actually converting a VB script code to C#.. Where it is checking the Shared path already connected or not.. If it is connected it will ask for disconnection else it will ask for connection.Please find the code snippet
Dim intI
Dim objDrives

DriveIsConnected = False
Set objDrives = objNetwork.EnumNetworkDrives
For intI = 0 To objDrives.Count - 1 Step 2
strDriveLetter = objDrives.Item(intI)
strNetworkDrivePath = objDrives.Item(intI + 1)
If strNetworkDrivePath = strPPath Then
DriveIsConnected = True

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900