简体   繁体   English

如何在Visual Studio中引用工作区目录

[英]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.

相关问题 如何引用添加到Visual Studio解决方案的项目? - How do I reference items that I add to Visual Studio solution? 如何在Visual Studio 2008中使用C#为其他窗口创建工作区窗口? - How do I create a workspace window for other windows using c# in visual studio 2008? 如何在Visual Studio Code中添加对HTMLAgilityPack的引用 - How do I add a reference to HTMLAgilityPack in Visual Studio Code 如何在 Visual Studio 的 C# 中创建服务引用? - How do I create a Service Reference in C# in Visual Studio? 如何在带有XNA的Visual Studio 2010中正确引用内容? - How do I properly reference Content in Visual Studio 2010 with XNA? 并发修改Roslyn工作区? Visual Studio如何做到这一点? - Concurrency of modifying a Roslyn workspace? How does Visual studio do it? 如何在 Visual Studio 2019 中添加对新 Windows Forms 项目的引用 - How do I add a Reference to a new Windows Forms Project in Visual Studio 2019 我如何在我的 Visual Studio 代码项目中正确引用 microsoft ASPNETCORE Identity? - how do i propeply reference microsoft ASPNETCORE Identity in my project for visual studio code? 如何在Visual Studio 2013中将Web参考从一种解决方案复制到另一种 - How do I copy a web reference from one solution to another in Visual Studio 2013 如何公开由类库引用的类库,该类库随后作为项目引用包含在Visual Studio中? - How do I expose class libraries referenced by a class library, which is then included as a project reference in Visual Studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM