How to force project to work only within it's directory?

91 views Asked by At

I am writing a solution with two projects, say, 'Core' and 'App'. App is only used to test Core. Core uses some data in it's directory. But the problem is, when I call Core methods that use those files, CLR searches for them in Solution\App\Debug\bin instead of Solution\Core\Debug\bin. That means that I have to copy files to App folder. Is there any way to avoid that?

1

There are 1 answers

0
BgrWorker On

It looks like your core project is being referenced by your app project. By default an executable has, as his current path, the folder where it is started (In this case, Solution\App\Debug\bin). Since it looks like your Core project needs another application to run, it most likely is some kind of class library, that usually has no external files.

One option would be to set a config value to the position of the files, so Core would know where to look (remember, if your Core project is a class library and gets imported as a dll, its config file needs to be called [DLL name].dll.config to work).

A second option would be to add this files to Project Resources (https://msdn.microsoft.com/en-us/library/7k989cfy%28v=vs.90%29.aspx).