运行Visual Studio作为管理员没有看到映射网络驱动器驱动器、管理员、网络、Visual

由网友(她的他,)分享简介:我有一个问题, 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 e...

我有一个问题, 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:poolmanLY212015LY21_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.

这不是关于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:poolmanLY212015LY21_2015-03-25_03.xml}
    base: {P:poolmanLY212015LY21_2015-03-25_03.xml}
    _name: "LY21_2015-03-25_03.xml"
    Directory: {P:poolmanLY212015}
    DirectoryName: "P:poolmanLY212015"
    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.

请参阅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 (serversharefile.xml).

阅读全文

相关推荐

最新文章