【发布时间】:2018-05-07 06:17:06
【问题描述】:
我有上传 excel 文件的方案。我将该文件复制到我的解决方案中,并使用下面的代码来获取文件路径,当我在本地运行它时可以上传。问题是当我在构建完成后尝试执行测试用例时出现错误,因为它无法调整文件路径。
string fileLocation = Path.Combine(Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.FullName);
fileLocation = fileLocation + "\\BDD.Automation.files\\TestData\\testfile.xlsm";
【问题讨论】:
-
您应该在尝试移动文件之前使用Directory.Exists()。
-
我尝试实现下面的代码出错了。
-
你检查过
fileLocation是否存在吗? -
请同时包含显示给您的错误。你的错误是
FileNotFoundException吗? -
嗨 Felix,Directory.GetParent() 方法能够读取文件路径,但 Directory.exists() 返回 false 并且 fileLocation 存在。
标签: c# selenium tfs azure-pipelines