【问题标题】:Read file from TFS and use it to upload in C#从 TFS 读取文件并使用它在 C# 中上传
【发布时间】: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


【解决方案1】:

感谢您的快速支持。我找到了这个问题的解决方案。上面的代码工作正常。问题出在 IWebDriver,因为它不支持在浏览器堆栈中上传文件。使用 RemoteWebDriver 来满足这个要求,它就像一个魅力。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-02
    • 1970-01-01
    • 2016-03-08
    • 1970-01-01
    • 2010-10-20
    相关资源
    最近更新 更多