获取内的Application_Start当前应用程序的物理路径 [英] Get current application physical path within Application_Start

查看:673
本文介绍了获取内的Application_Start当前应用程序的物理路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能用得到内的Application_Start当前的物理路径

  HttpContext.Current.Request.PhysicalApplicationPath

因为没有请求当时的对象。

怎么回事,我可以得到的物理路径?


解决方案

 保护无效的Application_Start(对象发件人,EventArgs的发送)
 {
     字符串路径=使用Server.Mappath(/);
     //要么
     串PATH2 =使用Server.Mappath(〜);
     //取决于你的应用需求 }

I'm not able to get the current physical path within Application_Start using

HttpContext.Current.Request.PhysicalApplicationPath

because there is no Request object at that time.

How else can I get the physical path?

解决方案

 protected void Application_Start(object sender, EventArgs e)
 {
     string path = Server.MapPath("/");
     //or 
     string path2 = Server.MapPath("~");
     //depends on your application needs

 }

这篇关于获取内的Application_Start当前应用程序的物理路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆