[英]how do I reference a workspace directory in Visual Studio
I am using visual studio 2008 and I have a few files that I want to reference when in #debug mode. 我使用的是Visual Studio 2008,在#debug模式下,我想参考一些文件。 How do I get the directory of the workspace so that I do not have to manually change it every time I am at a different computer? 如何获取工作空间的目录,以便不必每次在其他计算机上都手动更改它?
For instance, when I'm at work, my workspace is in c:\\work2, when I'm at home, it is in d:\\work. 例如,当我在工作时,我的工作空间在c:\\ work2中,当我在家时,它的工作空间在d:\\ work中。
This isn't an issue on the live product but it is when I change computers or other uses load the project since the files are in different directories for each workspace. 这不是实时产品上的问题,而是我更换计算机或其他用途时加载项目的原因,因为每个工作区的文件位于不同的目录中。
thanks! 谢谢! Eroc 埃罗克
Add the test files (XML, spreadsheet, etc) as a 'Resource.' 将测试文件(XML,电子表格等)添加为“资源”。 How to Add a Resource to your Project 如何向项目添加资源
Then, in your test files, you can use a relative address to access those files. 然后,在测试文件中,您可以使用相对地址来访问这些文件。
private const String = "./testFile1.xml";
您可以使用一些预构建命令来更改目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.