ASPNET下的路径辅助类
2010-07-21 15:51 Tracy. 阅读(224) 评论(0) 编辑 收藏 举报using System;
using System.Web;
namespace SysClassLibrary.Common
{
/// <summary>
/// Application 的摘要说明。
/// 网站相关路径信息
/// </summary>
public class Application :System.Web.HttpApplication
{
public Application()
{
this.Init();
}
#region 初始化
public override void Dispose()
{
base.Dispose ();
}
public override void Init()
{
base.Init ();
}
#endregion
#region 相关参数
/// <summary>
/// 应用程序对应物理目录
/// </summary>
public static string PhysicalApplicationPath
{
get
{
return HttpContext.Current.Request.PhysicalApplicationPath;
}
}
/// <summary>
/// 应用程序文件物理路径
/// </summary>
public static string PhysicalPath
{
get
{
return HttpContext.Current.Request.PhysicalPath;
}
}
/// <summary>
/// 应用程序虚拟目录名称
/// </summary>
public static string ApplicationPath
{
get
{
return HttpContext.Current.Request.ApplicationPath;
}
}
/// <summary>
/// Javascript脚本目录地址 :http://localhost/hwe/cmdjs/
/// </summary>
public static string JsFilesPath
{
get
{
return ApplicationPathUrl+ "/cmdjs/ ";
}
}
/// <summary>
/// Style样式表目录地址 :http://localhost/hwe/cmdimg/
/// </summary>
public static string StyleFilePath
{
get
{
return ApplicationPathUrl+ "/cmdimg/ ";
}
}
/// <summary>
/// XmlDocument 虚拟目录位置
/// </summary>
public static string XmlDocumentPath
{
get
{
return PhysicalApplicationPath +@ "XmlDocument\ ";
}
}
/// <summary>
/// 应用程序地址 :http://localhost/hwe
/// </summary>
public static string ApplicationPathUrl
{
get
{
HttpContext c = HttpContext.Current ;
if(HttpContext.Current.Server.MapPath( ". ")!= "/ ")
return "http:// "+System.Net.Dns.GetHostName()+ApplicationPath;
else
return "http:// "+System.Net.Dns.GetHostName();
}
}
/// <summary>
/// 应用程序签名路径
/// </summary>
public static string IdiographPath
{
get
{
return ApplicationPathUrl+ "/qm/ ";
}
}
#endregion
}
}
本文来自博客园,作者:Tracy.,转载请注明原文链接:https://www.cnblogs.com/tracy/archive/2010/07/21/1782277.html