Class VirtualPathUtilityEx

Inheritance
System.Object
VirtualPathUtilityEx
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Web
Assembly: EPiServer.Framework.dll
Version: 11.20.7
Syntax
public static class VirtualPathUtilityEx

Fields

AppDataPathKey

Declaration
public const string AppDataPathKey = "[appDataPath]"
Field Value
Type Description
System.String

Methods

AppendTrailingSlash(String)

Appends the literal slash mark (/) to the end of the virtual path, if one does not already exist.

Declaration
public static string AppendTrailingSlash(string virtualPath)
Parameters
Type Name Description
System.String virtualPath

The virtual path to append the slash mark to.

Returns
Type Description
System.String

The modified virtual path.

Combine(String, String)

Combines a base path and a relative path, but works in a non ASP.NET-hosted environment, and assumes that the relative path is relative - even if it begins with a slash.

Declaration
[Obsolete("If targeting ASP.NET use VirtualPathHelper.Combine instead")]
public static string Combine(string basePath, string relativePath)
Parameters
Type Name Description
System.String basePath

The base path.

System.String relativePath

The relative path.

Returns
Type Description
System.String

The combined basePath and relativePath.

Remarks

Extends "System.Web.VirtualPathUtility.Combine" to make it work in a non ASP.NET-hosted environment. Also allows all combos of trailing slash on basePath and leading on relativePath (i.e. will treat a 'faulty' relative path starting with a slash as a relative anyway. This is formally incorrect, but pragmatically useful due to other EPiServer API:s that for historical reasons work with such 'rooted' paths.

GetExtension(String)

Gets the extension for a file referenced in the virtual path.

Declaration
public static string GetExtension(string virtualPath)
Parameters
Type Name Description
System.String virtualPath

The virtual path.

Returns
Type Description
System.String

IsValidVirtualPath(String)

Determines whether the given candidate has a valid virtual path syntax.

Declaration
[Obsolete("If targeting ASP.NET use VirtualPathHelper.IsValidVirtualPath instead")]
public static bool IsValidVirtualPath(string candidate)
Parameters
Type Name Description
System.String candidate

The candidate virtual path string.

Returns
Type Description
System.Boolean

true if the string is not null or empty and has a valid virtual path syntax; otherwise, false.

RebasePhysicalPath(String)

Rebases the physical path according to the AppDataPathKey value, environment variables and relative paths.

Declaration
public static string RebasePhysicalPath(string path)
Parameters
Type Name Description
System.String path

The path.

Returns
Type Description
System.String
Exceptions
Type Condition
System.ArgumentException

if the path contains AppDataPathKey and the it's value is not configured in the config file.

RemoveTrailingSlash(String)

Removes a trailing slash mark (/) from a virtual path if it exists

Declaration
public static string RemoveTrailingSlash(string virtualPath)
Parameters
Type Name Description
System.String virtualPath

The virtual path to remove any trailing slash mark from

Returns
Type Description
System.String

A virtual path without a trailing slash mark, if the virtual path is not already the root directory ("/"); otherwise, null.

ToAbsolute(String)

Converts a virtual path to an application absolute path.

Declaration
[Obsolete("Use IVirtualPathResolver instead")]
public static string ToAbsolute(string virtualPath)
Parameters
Type Name Description
System.String virtualPath

The virtual path to convert to an application-relative path

Returns
Type Description
System.String

The absolute path representation of the specified virtual path.

Remarks

Extends "System.Web.VirtualPathUtility.ToAbsolute(string,string)" to make it work in a non ASP.NET-hosted environment.

ToAppRelative(String)

Converts a virtual path to an application-relative path.

Declaration
[Obsolete("Use IVirtualPathResolver instead")]
public static string ToAppRelative(string virtualPath)
Parameters
Type Name Description
System.String virtualPath

The virtual path to convert to an application-relative path.

Returns
Type Description
System.String

The application-relative path representation of virtualPath.

Remarks

Extends "System.Web.VirtualPathUtility.ToAppRelative(string,string)" to make it work in a non ASP.NET-hosted environment.

ValidatePhysicalPath(String)

Validates the physical path for the specified path string.

Declaration
public static void ValidatePhysicalPath(string physicalPath)
Parameters
Type Name Description
System.String physicalPath

The physical path.

Remarks

Throw ArgumentException If the physicalPath is different from the full path.