All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
用Asp.Net获取目录的方法_[Asp.Net教程]

Writer: delv Article type: Programming skills(编程技巧) Time: 2014/1/24 9:16:15 Browse times: 338 Comment times: 0

用Asp.Net获取目录的方法_[Asp.Net教程]


Head photo

Go homepage
Upload pictures
Write articles

用Asp.Net获取目录的方法_[Asp.Net教程] 学习asp.net上传文件时,发现有三种方法可以获取当前web程序目录物理路径:

方法一:
string sPath = System.IO.Path.GetDirectoryName(Page.Request.PhysicalPath);

方法二:
string sPath = System.Web.HttpContext.Current.Request.MapPath("images/");  //("images/")是当前虚拟目录下的任意目录

方法三:
string sPath = Page.Server.MapPath("images/");  //("images/")是当前虚拟目录下的任意目录
sPath = Page.Server.MapPath(".");  //当前目录

另:获取全路径中的文件名
string sFile = System.IO.Path.GetFileName(sFile);




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.