File path to my self

Sometimes when you are working and backend with code that could be in diffrent types of context, called from a ASP.NET client or winform, unit test or something else. Using relative path to files could be a problem. This code could then be usefull.

static string AssemblyDirectory
{
get
{
var codeBase = Assembly.GetExecutingAssembly().CodeBase;
var uri = newUriBuilder(codeBase);
var path = Uri.UnescapeDataString(uri.Path);
returnPath.GetDirectoryName(path);
}
}