This post originated from an RSS feed registered with .NET Buzz
by Chris Flaat.
Original Post: Adding linked items to projects
Feed Title: Chris Flaat's Weblog
Feed URL: /msdnerror.htm?aspxerrorpath=/cflaat/Rss.aspx
Feed Description: I mainly discuss tips & tricks about VS 2002, VS 2003, and upcoming versions of VS.
One little tip before I leave town. A very useful but well-hidden feature is
that of "linked files" within a VB or C# project. This lets you point to
a file without having it be copied into the same directory of your project.
You still get syntax coloring, intellisense, etc. Here's an example of how to
do this for a C# WinForms app using VS 2003 (but it should work the same in VS 2002).
Create a C# WinForms application project, e.g. named WindowsApplication1. Now
do Project.Add Existing Item (or hit ctrl+D, or right-click on the project node and
do Add / Add Existing Item). Find the file you want to link to -- a .cs
file in some other directory -- BUT DON'T hit the Open button yet!!! Click
the little down-arrow to the right of the Open button and a little menu will pop up.
Pick the bottom entry, "Link File", and click on it.
Boom! The file you chose is now part of your project, and its icon in the
solution explorer is now a little different than the others -- it has a little arrow
pointer to indicate that it's a linked file and not sucked into the project directory
like the others.