运行Visual Studio作为管理员没有看到映射网络驱动器 [英] Running Visual Studio as Administrator does not see mapped network drives

查看:704
本文介绍了运行Visual Studio作为管理员没有看到映射网络驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题, File.Exists()(不)工作的方式:当我使用它,它声称该文件不存在(从即时窗口):

I've a problem with the way File.Exists() (doesn't) work: when I use it, it claims that the file doesn't exist (from Immediate Window):

filePath
"P:\\poolman\\LY21\\2015\\LY21_2015-03-25_03.xml"
File.Exists(filePath)
false

但是,如果我复制/粘贴的文件路径资源管理器窗口的URL(去掉逃逸 \ 它打开文件

所以 File.Exists()声称,现有的文件不存在该来烦我。

So File.Exists() claims that an existing file doesn't exist which bug me.

这不是关于<一个href="http://stackoverflow.com/questions/11210408/file-exists-incorrectly-returns-false-when-path-is-too-long">length路径(这是43),的FileInfo 不是一个更好的选择,因为提出的这里

It's not about the length of the path (which is 43) and FileInfo is not a better option as suggested here.

下面是结果的的FileInfo 查询:

var f = new FileInfo(filePath);
{P:\poolman\LY21\2015\LY21_2015-03-25_03.xml}
    base: {P:\poolman\LY21\2015\LY21_2015-03-25_03.xml}
    _name: "LY21_2015-03-25_03.xml"
    Directory: {P:\poolman\LY21\2015}
    DirectoryName: "P:\\poolman\\LY21\\2015"
    Exists: false
    IsReadOnly: true
    Length: '(var f = new FileInfo(filePath);).Length' threw an exception of type 'System.IO.FileNotFoundException'
    Name: "LY21_2015-03-25_03.xml"

我怎么能解决呢?

How could I deal with it?

推荐答案

如果你运行一个程序(如Visual Studio)升高(如在评论声称),它没有运行作为当前的Windows用户,但管理员。

If you run a process (such as Visual Studio) elevated (as you claim in comments), it's not running as your current Windows user, but as Administrator.

管理员没有您的用户具有驱动器映射。所以,你的Visual Studio无法看到点:驱动的。一切都如预期。

Administrator does not have the drive mappings that your user has. So your Visual Studio cannot see the P: drive at all. All is working as intended.

请参阅<一href="http://superuser.com/questions/105173/how-to-access-network-shares-from-an-elevated-process-in-windows-7">How从一个提升的进程访问网络共享在Windows 7 :?使用UNC路径共享( \\服务器\共享\ file.xml

See How to access network shares from an elevated process in Windows 7?: use the UNC path to the share (\\server\share\file.xml).

这篇关于运行Visual Studio作为管理员没有看到映射网络驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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