c# - VS2013 与 VS2010 不同,我无法从 Windows 应用程序访问网络驱动器

标签 c# security networking visual-studio-2013 mapped-drive

<分区>

我无法解决这个问题!

创建一个只执行 FileInfo("Y:/test.txt") 的 VS2010 Windows 应用程序,并且在调试 FileInfo 时工作正常。

通过 VS2013 执行完全相同的操作,它报告找不到文件。

因此存在某种信任或模拟问题,虽然这是一个 Windows 应用程序,但我正在以管理员身份运行 VS2013。

这让我抓狂 - 有人有什么想法吗?

谢谢 保罗

最佳答案

当在 Windows 中启用 UAC 并且您是管理员组的成员时,您实际上会以两个登录 session 结束 - 一个作为普通用户,一个作为管理员。您的映射驱动器仅与您的常规用户登录 session 相关联,因此当您以管理员身份运行程序时,它看不到映射驱动器。

This link提供了更多详细信息和涉及更改注册表的解决方法(我自己还没有尝试过!):

To work around this problem, configure the EnableLinkedConnections registry value. This value enables Windows Vista and Windows 7 to share network connections between the filtered access token and the full administrator access token for a member of the Administrators group. After you configure this registry value, LSA checks whether there is another access token that is associated with the current user session if a network resource is mapped to an access token. If LSA determines that there is a linked access token, it adds the network share to the linked location. To configure the EnableLinkedConnections registry value

  1. Click Start, type regedit in the Start programs and files box, and then press ENTER.

  2. Locate and then right-click the registry subkey HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System.

  3. Point to New, and then click DWORD Value.

  4. Type EnableLinkedConnections, and then press ENTER.

  5. Right-click EnableLinkedConnections, and then click Modify.

  6. In the Value data box, type 1, and then click OK.

  7. Exit Registry Editor, and then restart the computer.

关于c# - VS2013 与 VS2010 不同,我无法从 Windows 应用程序访问网络驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21887453/

相关文章:

c# - 在 c# winform 应用程序中使用安装的字体时出现问题

c# - CouchDB 存储与 C# 中的同步(复制)

c# - 无法使用 c# 导航到 Windows Metro App 上的页面

security - HTTPS header 或帖子正文更安全吗?

networking - 丢弃 TCP 连接,这正常吗?

c++ - 杀死具有套接字的单独线程

c# - IdentityServer - 如何向客户端凭证 token 添加额外声明?

php - 安全认证

ios - 使用我自己的服务器验证 iOS 应用内购买

networking - 串行通讯在 WinXP 中死机