How to access content inside class library when run in a website
<p>I have a class library name "VirusScanManager" that contains a folder named "Lib". This folder contains a command-line scanner exe and supporting files. All these files have "Build Action" set to "Content" and "Copy to Output Directory" set to "copy always".</p>

<p>Inside the library I get the path to the folder using the following line:</p>

<pre><code>string virusCheckFolder 
= Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Lib");
</code></pre>

<p>I have a Tests class library with a reference to VirusScanManager. When the tests are run the <code>virusCheckFolder</code> is set to </p>

<p><code>C:\...\Projects\WebSiteMobileAdmin\Tests\bin\Debug\Lib</code> </p>

<p>and this works because the files are copied there.</p>

<p>I also have a BusinessLogicLayer class library with a reference to VirusScanManager. When I run my website the <code>virusCheckFolder</code> is set to </p>

<p><code>C:\...\WebSites\WebSiteMobileAdmin\Lib</code></p>

<p>this doesn't work because the files are actually copied to </p>

<p><code>C:\...\Projects\WebSiteMobileAdmin\BusinessLogic\bin\Debug\Lib</code></p>

<p>I then tried reflection as suggested by Beaner:</p>

<pre><code>string pathToDLL = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", ""));
string virusCheckFolder = Path.Combine(pathToDLL, "Lib");
</code></pre>

<p>This gives me</p>

<p><code>C:\...\WebSites\WebSiteMobileAdmin\Bin\Lib</code></p>

<p>But this folder does not exist.
I have a reference to BusinessLogicLayer in WebsiteMobileAdmin, and a reference to VirusScanManager in BusinessLogicLayer . It appears that when I do a build, the dll is created in both BusinessLogicLayer\bin\debug and WebsiteMobileAdmin\bin, but the lib folder is only copied to BusinessLogicLayer\bin\debug.</p>

<p>So, is there a way to get the path to the internal library that works for both scenarios?</p>
