Shared .cs files, and file locations

D

Dan Baker

I'm relatively new to the .cs world. I would like to have some "shared" .cs
files, which several solutions can use. I don't want to place these in a
..dll, I simply want them included into various applications. I have tried
several methods, but most have failed. The most obvious way (I thought) was
to place the .cs files in a parent folder (maybe called "shared"), and then
simply drag-n-drop the files into the "Solution Explorer" (files list) --
But, this actually copies the files into the folder where the solution
exists.

Is there some way to have a folder with many .cs files in it, and have those
..cs files be included in several solutions?

Any suggestions, pointers concepts, ideas?
Thanks
DanB


The only idea I currently have is as follows:
1) Have a main project folder: "C:\Projects\"
2) Place the solution files for every project in this folder (this includes:
..sln, .slu, .csproj, .csproj.user)
(Note: This seems like a huge pain. Every project solution files are in
the same folder! Yuck!)
project1.*
project2.*
project3.*
...
3) Each project would have a folder for the project files:
"C:\Projects\project1"
Form1.cs
App.ico
bin\
...
4) Have a "shared" folder: "C:\Projects\Shared"
Shared.cs
OtherShared.cs
...
5) Now, all the projects can include the shared .cs files, and only have
*one* copy of them also.
 
D

Dan Baker

Fantastic!
Thank you * 1Gig.
DanB

The part from the discussion I was looking for I copied below:
"When you add the code file to the project make sure that you specify it as
a
"link file". So in the "Add Existing Item" dialog, after you select the
DM.cs file, select the drop down arrow on the "Open" button and then select
"Link File". The file will now appear in the Solution Explorer, under the
appropriate project, with a code file icon that looks like it has a little
shortcut image over top of it."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top