System.Web 2.0.0.0 System.Object

The class provides utility methods for common operations involving virtual paths. For ASP.NET server controls and server code, virtual paths using the Web application root operator, the tilde (~), commonly are used instead of relative and absolute paths. For more information, see ASP.NET Web Site Paths.

Use the class when you need to convert application-relative paths to absolute virtual paths, as might be the case in developing a custom Web service handler.

An absolute virtual path starts with the literal slash mark (/). A relative virtual path is relative to the application root directory, if it is just a tilde (~) or starts with the tilde and a double backslash (~\\) or the tilde and a slash mark (~/). Making a virtual path relative makes the path independent of the application.

The virtual directory for the application can be obtained from the and properties.

The class is not intended for security or canonicalization purposes. For more information about Web application security, see Overview of Web Application Security Threats. For generic URL processing functionality, see .

Provides utility methods for common virtual path operations.

- Method
  System.String ``

  If the literal slash mark (/) exists at the end of the virtual path, the virtual path is not modified.

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

  The modified virtual path.

  The virtual path to append the slash mark to. 2.0.0.0
- Method
  System.String `` ``

  The method returns the value of the property if the relative path is exactly a tilde (~).

  The method uses the property value rather than the base path, if the relative path starts with a tilde and a slash mark (~/); otherwise, the method uses the base path.

  Combines a base path and a relative path.

  The combined and .

  The base path. The relative path. 2.0.0.0
- Method
  System.String ``

  If is not rooted; that is, it does not equal the root operator (the tilde [~]), does not start with a tilde (~), such as a tilde and a slash mark (~/) or a tilde and a double backslash (~//), or does not start with a slash mark (/), an exception is thrown.

  If the virtual path that is passed into the method is "/images/image1.gif", the returned directory is "/images".

  Returns the directory portion of a virtual path.

  The directory referenced in the virtual path.

  The virtual path. 2.0.0.0
- Method
  System.String ``

  If the virtual path that is passed into the method is "/images/image1.gif", the returned extension is ".gif".

  Retrieves the extension of the file that is referenced in the virtual path.

  The file name extension string literal, including the period (.), null, or an empty string ("").

  The virtual path. 2.0.0.0
- Method
  System.String ``

  If the virtual path that is passed into the method is "/images/image1.gif", the returned file name is "image1.gif".

  Retrieves the file name of the file that is referenced in the virtual path.

  The file name literal after the last directory character in ; otherwise, the last directory name if the last character of is a directory or volume separator character.

  The virtual path. 2.0.0.0
- Method
  System.Boolean ``

  A virtual path is absolute if it begins with a literal slash mark (/). For example, the property returns an absolute virtual path.

  Returns a Boolean value indicating whether the specified virtual path is absolute; that is, it starts with a literal slash mark (/).

  true if is an absolute path and is not null or an empty string (""); otherwise, false.

  The virtual path to check. 2.0.0.0
- Method
  System.Boolean ``

  The virtual path can be just the root operator (the tilde [~]), or it can begin with the root operator. If is null, an exception is raised. If is an empty string (""), the method returns false.

  "~" is not a valid virtual path and returns false for the method.

  Returns a Boolean value indicating whether the specified virtual path is relative to the application.

  true if is relative to the application; otherwise, false.

  The virtual path to check. 2.0.0.0
- Method
  System.String `` ``

  If the and parameters are not rooted; that is, they do not equal the root operator (the tilde [~]), do not start with a tilde (~), such as a tilde and a slash mark (~/) or a tilde and a double backslash (~//), or do not start with a slash mark (/), an exception is thrown.

  Query string parameters and HTML anchors that are used in the URI are not used in determining the relative path.

  If is "/directory1/file1.aspx" and is "/directory2/file2.aspx", the method returns "../directory2/file2.aspx".

  Returns the relative virtual path from one virtual path containing the root operator (the tilde [~]) to another.

  The relative virtual path from to .

  The starting virtual path to return the relative virtual path from. The ending virtual path to return the relative virtual path to. 2.0.0.0
- Method
  System.String ``

  The method removes a slash mark (/) from the end of the virtual path. If the virtual path is already the root directory ("/"), no action is taken. If the virtual path is null or an empty string (""), the method returns null.

  Removes a trailing slash mark (/) from a virtual path.

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

  The virtual path to remove any trailing slash mark from. 2.0.0.0
- Method
  System.String ``

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

  If is:

  Absolute, the method returns the virtual path unchanged.

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

  Not rooted, the method raises an exception.

  Converts a virtual path to an application absolute path.

  The absolute path representation of the specified virtual path.

  The virtual path to convert to an application-relative path. 2.0.0.0
- Method
  System.String `` ``

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

  If is:

  Absolute, the method returns the virtual path with no changes.

  Application relative, the method adds to the beginning of the virtual path.

  Not rooted, the method raises an exception.

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

  The absolute virtual path representation of .

  The virtual path to convert to an application-relative path. The application path to use to convert to a relative path. 2.0.0.0
- Method
  2.0.0.0
  System.String `` `` `` To be added. To be added. To be added. To be added. To be added. To be added.
- Method
  System.String ``

  If the virtual path for the application is "myapp" and the virtual path "/myApp/sub/default.asp" is passed into the method, the resulting application-relative path is "~/sub/default.aspx".

  If does not start with the current application path, the method returns the virtual path unchanged.

  If is the same as the application path, the root operator (the tilde [~]), is returned. For example, the current application virtual directory path can be accessed from the property.

  Converts a virtual path to an application-relative path using the application virtual path that is in the property.

  The application-relative path representation of .

  The virtual path to convert to an application-relative path. 2.0.0.0
- Method
  System.String `` ``

  The overload of the method uses rather than the current application path. If does not start with , the method returns the virtual path unchanged.

  Converts a virtual path to an application-relative path using a specified application path.

  The application-relative path representation of .

  The virtual path to convert to an application-relative path. The application path to use to convert to a relative path. 2.0.0.0