I’m trying to get the path to the ClientBin directory from within my .Web project inside a Silverlight application. Currently, my method looks like this, but there has to be a better/more concise way to get this path:
public static string GetClientBinPath()
{
var applicationPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
if (applicationPath.StartsWith(@"file:\"))
applicationPath = applicationPath.Remove(0, 6);
applicationPath = Path.Combine(applicationPath, @"..\ClientBin");
return applicationPath;
}
In the Web project you should use the static method MapPath of the HostingEnvironment class.
The class is located in the System.Web.Hosting namespace of the assembly System.Web