WORK IN PROGRESS, GET THE STABLE SOURCE FROM THE DOWNLOADS TAB

Fixes 26116

[TFS Changeset #63765]
This commit is contained in:
hartvig
2010-02-03 11:49:54 +00:00
parent 97d642a562
commit 3372da8225

View File

@@ -11,6 +11,8 @@ namespace umbraco.IO
{
public class IOHelper
{
private static string m_rootDir = "";
public static char DirSepChar
{
get
@@ -54,7 +56,8 @@ namespace umbraco.IO
}
else
{
string _root = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath.TrimEnd(IOHelper.DirSepChar);
string _root = (!String.IsNullOrEmpty(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath)) ? System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath.TrimEnd(IOHelper.DirSepChar) : getRootDirectorySafe();
string _path = path.TrimStart('~','/').Replace('/', IOHelper.DirSepChar);
string retval = _root + IOHelper.DirSepChar.ToString() + _path;
@@ -86,5 +89,25 @@ namespace umbraco.IO
}
/// <summary>
/// Returns the path to the root of the application, by getting the path to where the assembly where this
/// method is included is present, then traversing until it's past the /bin directory. Ie. this makes it work
/// even if the assembly is in a /bin/debug or /bin/release folder
/// </summary>
/// <returns></returns>
private static string getRootDirectorySafe() {
if (!String.IsNullOrEmpty(m_rootDir))
{
return m_rootDir;
}
string baseDirectory =
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase.Substring(8));
m_rootDir = baseDirectory.Substring(0, baseDirectory.LastIndexOf("bin")-1);
return m_rootDir;
}
}
}