Adding MapPath extension
This commit is contained in:
parent
19b75b688a
commit
f35bfcd271
|
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using Microsoft.Framework.Internal;
|
using Microsoft.Framework.Internal;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Hosting
|
namespace Microsoft.AspNet.Hosting
|
||||||
|
|
@ -23,5 +24,23 @@ namespace Microsoft.AspNet.Hosting
|
||||||
environmentName,
|
environmentName,
|
||||||
StringComparison.OrdinalIgnoreCase);
|
StringComparison.OrdinalIgnoreCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gives the physical path corresponding to the given virtual path.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hostingEnvironment">An instance of <see cref="IHostingEnvironment"/> service.</param>
|
||||||
|
/// <param name="virtualPath">Path relative to the root.</param>
|
||||||
|
/// <returns>Physical path corresponding to virtual path.</returns>
|
||||||
|
public static string MapPath(
|
||||||
|
[NotNull]this IHostingEnvironment hostingEnvironment,
|
||||||
|
string virtualPath)
|
||||||
|
{
|
||||||
|
if (virtualPath == null)
|
||||||
|
{
|
||||||
|
return hostingEnvironment.WebRootPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Path.Combine(hostingEnvironment.WebRootPath, virtualPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue