Class VirtualPathUtilityEx
Contains some convenient methods to manage virtual paths.
Inheritance
Namespace: EPiServer.Web
Assembly: EPiServer.Framework.dll
Version: 12.0.3Syntax
public static class VirtualPathUtilityEx : Object
Fields
AppDataPathKey
A const for the AppDataPath key
Declaration
public const string AppDataPathKey = "[appDataPath]"
Field Value
Type | Description |
---|---|
System. |
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. |
virtualPath | The virtual path to append the slash mark to. |
Returns
Type | Description |
---|---|
System. |
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
public static string Combine(string basePath, string relativePath)
Parameters
Type | Name | Description |
---|---|---|
System. |
basePath | The base path. |
System. |
relativePath | The relative path. |
Returns
Type | Description |
---|---|
System. |
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. |
virtualPath | The virtual path. |
Returns
Type | Description |
---|---|
System. |
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. |
path | The path. |
Returns
Type | Description |
---|---|
System. |
Exceptions
Type | Condition |
---|---|
System. |
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. |
virtualPath | The virtual path to remove any trailing slash mark from |
Returns
Type | Description |
---|---|
System. |
A virtual path without a trailing slash mark, if the virtual path is not already the root directory ("/"); otherwise, null. |
ValidatePhysicalPath(String)
Validates the physical path for the specified path string.
Declaration
public static void ValidatePhysicalPath(string physicalPath)
Parameters
Type | Name | Description |
---|---|---|
System. |
physicalPath | The physical path. |
Remarks
Throw ArgumentException If the physicalPath is different from the full path.