【问题标题】:C# Environment.GetDrives() not working correctly in administrator modeC# Environment.GetDrives() 在管理员模式下无法正常工作
【发布时间】:2011-06-10 12:26:52
【问题描述】:

当我在标准用户模式下运行此代码时,我得到了所有驱动器,包括网络驱动器。以管理员身份运行时,网络驱动器不会出现在列表中。什么给了?

List<string> drives = Environment.GetLogicalDrives().ToList();
StringBuilder driveList = new StringBuilder();

foreach (string drive in drives)
    driveList.AppendLine(drive);

MessageBox.Show(driveList.ToString());

这是在 Windows 7 下运行的。网络驱动器来自 Novell。代码使用 .NET 4 框架用 C# 编写。

【问题讨论】:

    标签: c# windows-7 uac elevated-privileges


    【解决方案1】:

    这是正常行为,因为 Windows Vista 网络映射驱动器不适用于以提升权限运行的进程(请参阅 Programs may be unable to access some network locations after you turn on User Account Control in Windows Vista or in Windows 7 (KB 937624))。知识库文章中的解决方法意味着注册表编辑和计算机重新启动。

    另请参阅博文 Mapped Network Drives with UAC on Windows Vista 了解更多详情。

    【讨论】:

      猜你喜欢
      • 2013-06-28
      • 1970-01-01
      • 2011-12-12
      • 1970-01-01
      • 2012-05-16
      • 1970-01-01
      • 2015-09-18
      • 1970-01-01
      • 2012-07-13
      相关资源
      最近更新 更多