Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
223 views
in Technique[技术] by (71.8m points)

c# - How do I add a reference to an external configuration file to Visual Studio 2010?

I have an external configuration file, for a third party tool, which I would like to be able to edit as part of editing other project components in VS2010.

The project I'm working on is an MVC-3 project, and the file is located outside of the folder structure for the project (it's in the equivalent of ../ExternalConfig to the root).

How do I add a reference to this file to VS2010? Currently, all my attempts have resulted in VS creating a copy of the file inside of its directory structure, which is not ideal.

(Sure, I could go to some strange lengths, like adding a script to the build process to put the config file in the right place, but I'd rather just be able to edit it where it sits)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The trick is to add the item as a link:

  1. Right-click your project in Solution Explorer
  2. Select "Add" -> "Existing Item..."
  3. Navigate to the file that you want to add to the solution
  4. [Important] Instead of hitting Enter or clicking the Add button, you want to click the down-arrow icon at the right edge of the Add button, and select "Add As Link".

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...