Adding MapPath extension

This commit is contained in:
Praburaj 2015-03-21 07:18:40 -07:00
parent 19b75b688a
commit f35bfcd271
1 changed files with 19 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.Hosting
@ -23,5 +24,23 @@ namespace Microsoft.AspNet.Hosting
environmentName,
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);
}
}
}