I have an ASP.NET website and I want to find the /bin/[Configuration] folder to use an external tool (an exe file). When I use reflection to get calling assemblies location it returns something similar to:
C:\Windows\Microsoft.NET\Framework\\...\Temporary ASP.NET Files\a1388a5e\\...\my.dll
Since each dll has its own directory under the temp ASP.NET Files this fails for me.
How can I get the location of the compiled binary folder where the dll's and the .exe is (i.e. bin/) instead of asp.net's temporary cache?
Notes
You could try (taken from How to: Get the Application Directory):
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
I set up a quick test with:
In the web application I created a page that called the following method from the library project:
using System.IO;
using System.Reflection;
namespace TestHelpers {
public class ClassHelpers {
public static string PathToBin() {
return Path.GetDirectoryName(
Assembly.GetExecutingAssembly().GetName().CodeBase);
}
}
}
This resulted in the following output on the page:
file:\C:\Users\ UserName \Documents\Visual Studio 2008\Websites\ Solution \ Project \bin
Which is what I'd expect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With