在以管理员身份运行 Visual Studio 时,无法看到映射的网络驱动器。

8 浏览
0 Comments

在以管理员身份运行 Visual Studio 时,无法看到映射的网络驱动器。

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

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

但是,如果我将文件路径复制/粘贴到资源管理器窗口的URL中(去掉转义字符\),它会打开文件

所以File.Exists()声称一个已存在的文件不存在,这让我很烦恼。

这与路径的长度(长度为43)无关,FileInfo也不是一个更好的选择,如这里所建议的。

这是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' 引发了类型为'System.IO.FileNotFoundException'的异常
    Name: "LY21_2015-03-25_03.xml"

我该如何处理这个问题?

0