System.IO.Path //处理路径类
ChangeExtension //把给定的路径字符串的扩展名改为新扩展名
Combine //从两个部分路径字符串中返回一个合并的路径
GetDirectoryName //返回给定路径的目录
GetExtension //返回给定路径的扩展名
GetFileName 返回给定路径的文件名
GetFileNameWithoutExtension 返回给定路径的文件名,但不带扩展名
GetFullPath 给定一个非根路径,根据当前的工作目录返回根路径名。例如:所传送路径是temp,当前工作目录是c:\mywebsite,则该方法返回c:\mywebsite\temp
GetInvalidFileNameChars 返回当前系统中的文件名不允许使用的字符数组
GetInvalidPathChars 返回当前系统中的路径名不允许使用的字符数组
GetPathRoot 返回根路径
GetTempPath 返回临时的目录名
HasExtension 返回一个布尔值,表示路径是否有扩展名
IsPathRooted 返回一个布尔值,表示路径是否是根目录
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
网站在服务器磁盘上的物理路径: HttpRuntime.AppDomainAppPath
虚拟程序路径: HttpRuntime.AppDomainAppVirtualPath
任何于Request/HttpContext.Current等相关的方法, 都只能在有请求上下文或者页面时使用. 即在无请求上下文时,HttpContext.Current为null. 而上面提到的方法一直可用.
对于全局Cache对象的访问亦然.
==================================================================================
示例:输出asp.net 网站路径。




















输出:当前时间: 2007-08-30 11:03:49
当前请求的虚拟路径: /aDirectory/Sample/responseHtml.aspx
获取当前应用程序的根目录路径: /aDirectory
当前请求的虚拟路径: /aDirectory/Sample/responseHtml.aspx
当前请求的虚拟路径: /aDirectory/Sample/responseHtml.aspx
获取当前正在执行的应用程序的根目录的物理文件系统路径: E:\Visual Studio 2005\
获取与请求的 URL 相对应的物理文件系统路径: E:\Visual Studio 2005\\aDirectory\
在ASP.NET编程中经常需要用Request获取url的有关信息.
测试的url地址是http://www.test.com/testweb/default.aspx, 结果如下:
Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path: /testweb/default.aspx
Request.PathInfo:
Request.PhysicalApplicationPath: E:\WWW\testweb\
Request.PhysicalPath: E:\WWW\testweb\default.aspx
Request.RawUrl: /testweb/default.aspx
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUri: http://www.test.com/testweb/default.aspx
Request.Url.Host: www.test.com
Request.Url.LocalPath:
转载于:https://blog.51cto.com/feelmanc/1250570