Reputation: 2247
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;
}
Upvotes: 2
Views: 5254
Reputation: 1
I know it is old but here you go:
currentDir = Path.GetDirectoryName(Application.Current.Host.Source.LocalPath);
It works for out of the browser application. I haven't test it in the browser.
Upvotes: 0