Assembly: System.Web (in system.web.dll)
The VirtualPathUtility 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 VirtualPathUtility 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 VirtualPathUtility 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 Uri.
The following code example demonstrates how to use the VirtualPathUtility class and some of its methods. First, the FilePath property generates the virtual path to the Web page. The GetFileName, GetExtension, and GetDirectory methods return information about the virtual path. Next, the CurrentExecutionFilePath property generates a virtual path of the current request, which might be different from the FilePath property, if a Redirect method was called. The IsAbsolute, IsAppRelative, and ToAppRelative methods return information about the virtual path.
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.