如何在我的计算机或用户计算机上获取所有映射的网络驱动器? [英] How Do I Get All The Mapped Network Drives On My Computer Or A Users Computer?

查看:161
本文介绍了如何在我的计算机或用户计算机上获取所有映射的网络驱动器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用下面的代码,但这只是给我C:\驱动器。我还有3个其他驱动器映射到我的计算机。任何帮助?我正在使用vb.net,这是一个Web应用程序。我也冒充我的代码。谢谢。



  Dim  drive 正如 System.IO.DriveInfo< big> < /   big  >  

对于 每个驱动器 System.IO.DriveInfo.GetDrives
如果 drive.DriveType = IO.DriveType.Network 然后
Dim str As 字符串 = drive.Name
结束 如果
下一步

解决方案

嗯......你确实意识到该代码永远不会在web ap中运行是的,不是吗?

这是VB代码:所以它运行在服务器上,而不是客户端 - 因此它会查看服务器上的驱动器,而不是其他计算机。很可能,Web服务器不会将任何驱动器映射到其他计算机......



实际上,您无法从客户端获取该信息:安全禁止它。您可以在某些(非常受限制的)情况下执行此操作,当用户运行IE时,将其计算机设置为执行ActiveX控件,并且您的计算机上有ActiveX控件 - 但在绝大多数情况下情况并非如此

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.

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

解决方案

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.


这篇关于如何在我的计算机或用户计算机上获取所有映射的网络驱动器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆