Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use the code below, but this is only giving me the C:\ drive. I have 3 more other drives mapped to my computer. any help? I am using vb.net and this is for a web application. I also have impersonation around my code. Thanks.

VB
Dim drive As System.IO.DriveInfo<big></big>

           For Each drive In System.IO.DriveInfo.GetDrives
           If drive.DriveType = IO.DriveType.Network Then
               Dim str As String = drive.Name
           End If
           Next
Posted
Updated 15-May-15 5:35am
v2

1 solution

Um...you do realize that that code is never going to work in a web application, don't you?
It's in VB code: so it runs on the Server, not the Client - and so it looks at the drives on the Server, and no other computer. In all probability, the web server is not going to have any drives mapped to other computers...

In practice, you can't get that information from the client: security prohibits it. You can do it in some (very restricted) case, when the user is running IE, has his computer set to execute ActiveX controls, and you have an ActiveX control on his computer - but that is not the case in the vast majority of cases.
 
Share this answer
 
Comments
Member 10736689 15-May-15 11:45am    
I know security prohibits this. But i was hoping someone would have a workaround (ActiveX). Instead of me having to go reinvent the wheel. That is why i specify that im using a web application
OriginalGriff 15-May-15 11:51am    
It's not likely.
ActiveX's only work under IE, and are disabled by default on "normal" installations. So given that the user base is really, really tiny it's unlikely that anyone else has found a need to do it! :laugh:
Member 10736689 15-May-15 11:55am    
Web applications at my company are to be designed for IE :(sadly). I have to find a way around this though. Users dont necessarily pay attention to the paths \\server\shared.. they only know the letter drives for the mapped folders. So we are trying to make this web application as user friendly as possible.

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