zoukankan      html  css  js  c++  java
  • ASP.NET中常用的两个路径

    在做.NET编程时,因为目录结构问题往往很难使用相对路径,而用应用程序的URL绝对路径来代替。但这样会涉及到应用程序名称,端口问题,我大概写了一个获取URL路径的方法

     URL绝对路径

                #region 生成url应用程序绝对路径
                
    string absPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
                absPath = absPath.Substring(System.Web.HttpContext.Current.Request.ApplicationPath.Length);
                
    string asbUrl = System.Web.HttpContext.Current.Request.Url.AbsoluteUri;
                
    this._apppath = asbUrl.Substring(0, asbUrl.IndexOf(absPath));
                
    this._apppath.TrimEnd('/');
                
    #endregion


    硬盘物理路径和皮肤路径

                #region 生成应用程序硬盘物理路径
                
    this._physicalpath = System.Web.HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"].ToString().TrimEnd('\\');
                
    #endregion

                
    #region 生成url应用程序皮肤绝对路径
                System.Web.Configuration.PagesSection _ps 
    = (System.Web.Configuration.PagesSection)System.Configuration.ConfigurationManager.GetSection("system.web/pages");
                
    this._themename = _ps.Theme;
                
    this._fullthemepath = string.Format("{0}/App_Themes/{1}"this._apppath, _ps.Theme).TrimEnd('/');
                
    #endregion


  • 相关阅读:
    Ubuntu中开启Telnet服务
    单片机串口通讯RXD与TXD如何对接详解
    KEIL, a Smart Comliler
    linux mail 命令(转载)
    VC程序在没装VC的机器中运行
    srand()以及rand()函数用法
    VC菜菜鸟:基于CFree的HelloWorld程序
    Keil使用中的若干问题(转)
    VMWARE 重新安装出错
    Linux个人学习笔记(编辑中)
  • 原文地址:https://www.cnblogs.com/freeton/p/1693930.html
Copyright © 2011-2022 走看看