获得包含在项目文件中的文件路径 [英] get file path for file included in project

查看:197
本文介绍了获得包含在项目文件中的文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立与硒的集成测试和需要上传的文件。我已经包括在我的项目文件,但我需要的完整路径进入到浏览器中,以检查是否浏览器上传系统的工作原理。

I am building an integration test with Selenium and need to upload a file. I have the file included in my project but I need the full path to enter into the browser, to check if the browser upload system works.

我怎样才能得到包括在我的项目中的文件的完整路径?该测试将在不同地点几个不同的机器上运行。

How can I get the full path of a file that is included in my project? The test will be run on several different machines from different locations.

推荐答案

您不需要。将其标记为复制到输出目录(右键单击在解决方案资源管理,并期待在道具),它总是会在你的工作目录,所以你可以使用相对路径,例如:

You don't need to. Mark it as 'Copy To Output Directory' (right click in Solution Explorer and look at the props) and it will always be in your working dir and so you can use a relative path, e.g.:

new StreamReader("myFileThatIMarkedAsCopyAlwaysInVisualStudio.txt");

这篇关于获得包含在项目文件中的文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆