VirtualPathUtility.ToAbsolute Method

Definition

Converts a virtual path to an application absolute path.

Overloads

ToAbsolute(String)

Converts a virtual path to an application absolute path.

ToAbsolute(String, String)

Converts a virtual path to an application absolute path using the specified application path.

ToAbsolute(String)

Converts a virtual path to an application absolute path.

C#
public static string ToAbsolute(string virtualPath);

Parameters

virtualPath
String

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

Returns

The absolute path representation of the specified virtual path.

Exceptions

virtualPath is not rooted.

A leading double period (..) is used to exit above the top directory.

Remarks

An application absolute path is one where the application path is used instead of the root operator (the tilde [~]).

If virtualPath is:

  • Absolute, the ToAbsolute method returns the virtual path unchanged.

  • Application relative, the ToAbsolute method appends the current application virtual directory path to the beginning of the virtualPath. For example, the current application virtual directory path can be accessed from the AppDomainAppVirtualPath property.

  • Not rooted, the ToAbsolute method raises an ArgumentOutOfRangeException exception.

See also

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

ToAbsolute(String, String)

Converts a virtual path to an application absolute path using the specified application path.

C#
public static string ToAbsolute(string virtualPath, string applicationPath);

Parameters

virtualPath
String

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

applicationPath
String

The application path to use to convert virtualPath to a relative path.

Returns

The absolute virtual path representation of virtualPath.

Exceptions

applicationPath is not rooted.

A leading double period (..) is used in the application path to exit above the top directory.

Remarks

The ToAbsolute overload of the ToAbsolute method uses the supplied application path rather than the current application path.

If virtualPath is:

See also

Applies to

.NET Framework 4.8.1 a ďalšie verzie
Produkt Verzie
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1