我的方式File.Exists()(不)工作有问题:当我使用它时,它声称该文件不存在(来自立即窗口):
filePath
"P:\\poolman\\LY21\\2015\\LY21_2015-03-25_03.xml"
File.Exists(filePath)
false
Run Code Online (Sandbox Code Playgroud)
但是,如果我将文件路径复制/粘贴到资源管理器窗口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' threw an exception of type 'System.IO.FileNotFoundException'
Name: "LY21_2015-03-25_03.xml"
Run Code Online (Sandbox Code Playgroud)
我怎么处理它?