From f35bfcd271a284edd8921e9528e820bd72f892f7 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Sat, 21 Mar 2015 07:18:40 -0700 Subject: [PATCH] Adding MapPath extension --- .../HostingEnvironmentExtensions.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Microsoft.AspNet.Hosting.Interfaces/HostingEnvironmentExtensions.cs b/src/Microsoft.AspNet.Hosting.Interfaces/HostingEnvironmentExtensions.cs index b39316a281..0af82fee14 100644 --- a/src/Microsoft.AspNet.Hosting.Interfaces/HostingEnvironmentExtensions.cs +++ b/src/Microsoft.AspNet.Hosting.Interfaces/HostingEnvironmentExtensions.cs @@ -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); } + + /// + /// Gives the physical path corresponding to the given virtual path. + /// + /// An instance of service. + /// Path relative to the root. + /// Physical path corresponding to virtual path. + public static string MapPath( + [NotNull]this IHostingEnvironment hostingEnvironment, + string virtualPath) + { + if (virtualPath == null) + { + return hostingEnvironment.WebRootPath; + } + + return Path.Combine(hostingEnvironment.WebRootPath, virtualPath); + } } } \ No newline at end of file