文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>asp.net 获取url路径方法

asp.net 获取url路径方法

时间:2011-01-06  来源:秩名

httpcontext.current.request.physicalpath; // 获得当前页面的完整物理路径.比如 f:xfu.nsqsprojectwebsitedefault.asp教程x
httpcontext.current.request.physicalapplicationpath; // 获得当前程序运行的物理路径比如f:xfu.nsqsprojectwebsite
httpcontext.current.server.mappath(@""); 这个就是在页面中的mappath了.一样用法

httpruntime.appdomainapppath //这个是新发现的,很好用.

 

还有一个是用来处理在asp.net教程中调用dll文件,而dll文件如果想知道当前的web站点的工作目录可以用system.appdomain.currentdomain.basedirectory


简单三种方法

习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/")是当前虚拟目录下的任意目录另:获取全路径中的文件名

string sfile = system.io.path.getfilename(sfile);

//获取当前进程的完整路径,包含文件名(进程名)。

string str = this.gettype().assembly.location;result: x:xxxxxxxxx.exe (.exe文件所在的目录+.exe文件名)

//获取新的 process 组件并将其与当前活动的进程关联的主模块的完整路径,包含文件名(进程名)。

string str = system.diagnostics.process.getcurrentprocess().mainmodule.filename;

 

标签分类: ASP.NET

相关阅读 更多 +
排行榜 更多 +
XLM币最具爆发力的安全交易所币安binance下载

XLM币最具爆发力的安全交易所币安binance下载

金融理财 下载
XEM币最安全隐私链的全球交易所币安binance下载

XEM币最安全隐私链的全球交易所币安binance下载

金融理财 下载
WAVES币最新上线的优质交易所币安binance下载

WAVES币最新上线的优质交易所币安binance下载

金融理财 下载