繁体   English   中英

当文件确实存在时,System.IO.File为什么返回false?

[英]How come System.IO.File is returning false when the file does exist?

我正在使用System.IO.File.Exists检查文件是否存在。 但是,对于我知道存在的文件,它返回false。 代码如下:

Assert.IsTrue(System.IO.File.Exists(@"\ImportRepositoryTest\Version2.xml"));

当文件确实存在时, System.IO.File为什么返回false?

尝试

Assert.IsTrue(System.IO.File.Exists(Path.Combine(TestContext.TestDeploymentDir,  @"\ImportRepositoryTest\Version2.xml")));

将其更改为Assert.IsTrue(System.IO.File.Exists(@".\\ImportRepositoryTest\\Version2.xml")); (带有“。”),然后再次检查是否将文件标记为“始终复制”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM