I have a WebSite project – ASPX, 4.0. In it I have a folder like:
bin\Xslt\Template.xslt
I want to load this file in my class library. In web.config is:
<configuration>
<appSettings>
<add key="Filepath" value=".\Xslt\Template.xslt" />
</appSettings>
</configuration>
But, my class library can’t find it:
mTransform = new XslCompiledTransform();
mTransform.Load(ConfigurationManager.AppSettings["Filepath"]);
throws: Could not find a part of the path 'C:\Xslt\Template.xslt'.
I know there’s a catch here, but I can’t remember the proper way…
How to reference a file in an aspx \bin\ folder correctly?
I found the way (since it’s in an assembly and I didn’t want to add dependency on System.Web):
Thanks
edit: The
System.AppDomain.CurrentDomain.BaseDirectoryalso does the trick…