次の方法で共有


Adding linked items to projects

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.

Off I go on vacation -- have a great 4th! -Chris

Comments

  • Anonymous
    July 03, 2003
    Welcome and thanks for the tip.
  • Anonymous
    July 08, 2003
    The comment has been removed
  • Anonymous
    July 10, 2003
    Too bad it isn't available for ASP.NET projects. Yet another reason it seems like creating them as library projects (while tedious) makes more sense.
  • Anonymous
    July 11, 2003
    Regarding putting linked items under source control, see my entry from today for a brief discussion of this.