Adding common class file to project but don't want to add it to the projects folders I am working on RRS feed

  • Question

  • So I am having one project directory that consists of my codes and exe files. C:\Project1\ and C:\Project2, etc. 

    Then I have another central directory that I have the cs class file that I always use for all the projects as well. C:\Projects\common.cs

    When I am working on Project 1 or Project 2, and right click on Project and add common.cs - VS automatically adds common.cs to my Project 1 and Project 2, so when I make any changes, it only changes the common.cs file in the Project 1 and Project 2. That's not what I want. I would like the changes to happen inside C:\Projects\common.cs so it will be good across the board without me having to go into each project to change the common.cs code.

    When I add the common.cs file, it should NOT add the file to Project1 and Project 2.

    Is that possible? 


    Tuesday, August 20, 2019 6:58 PM


  • If you already have a common.cs file in Projects folder and use “Add Existing Item” dialog in Project1 or Project2, see the Add button — it has an arrow that opens a submenu. Select “Add as link” from submenu.

    Or create a special “Class Library” project for common files. Then add it to solution that contains Project1 or Project2 and use “Add Reference” dialog to add a reference to common project. Then you will not have to add each file to main projects.


    • Edited by Viorel_MVP Tuesday, August 20, 2019 8:17 PM
    • Proposed as answer by BonnieBMVP, Moderator Wednesday, August 21, 2019 4:54 AM
    • Marked as answer by codebie Wednesday, August 21, 2019 3:21 PM
    Tuesday, August 20, 2019 8:14 PM