zoukankan      html  css  js  c++  java
  • Asp.net项目路径获取方法【转】

    获取项目完整的绝对路径
    string path = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
    string path = Server.MapPath(".");//此"."可以换成项目文件里的其它文件夹名称
     
    输出asp.net 网站路径
    private void responseHtml()
     {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(string.Format("当前时间: {0}", Server.HtmlEncode(DateTime.Now.ToString())));
            sb.Append("<br />");
            sb.Append(string.Format("当前请求的虚拟路径: {0}",Server.HtmlEncode(Request.CurrentExecutionFilePath)));
            sb.Append("<br />");
            sb.Append(string.Format("获取当前应用程序的根目录路径: {0}", Server.HtmlEncode(Request.ApplicationPath)));
            sb.Append("<br />");
            sb.Append(string.Format("当前请求的虚拟路径: {0}",Server.HtmlEncode(Request.FilePath)));
            sb.Append("<br />");
      sb.Append(string.Format("当前请求的虚拟路径: {0}",Server.HtmlEncode(Request.Path)));
            sb.Append("<br />");
            sb.Append(string.Format("获取当前正在执行的应用程序的根目录的物理文件系统路径: {0}", Server.HtmlEncode(Request.PhysicalApplicationPath)));
            sb.Append("<br />");
            sb.Append(string.Format("获取与请求的 URL 相对应的物理文件系统路径: {0}", Server.HtmlEncode(Request.PhysicalApplicationPath)));
            sb.Append("<br />");
            Response.Write(sb.ToString());
    }

    输出:当前时间: 2008-11-7 10:26:47
    当前请求的虚拟路径: /test/Gauge.aspx
    获取当前应用程序的根目录路径: /test
    当前请求的虚拟路径: /test/Gauge.aspx
    当前请求的虚拟路径: /test/Gauge.aspx
    获取当前正在执行的应用程序的根目录的物理文件系统路径: D:Asp.net测试项目 est
    获取与请求的 URL 相对应的物理文件系统路径: D:Asp.net测试项目 est

  • 相关阅读:
    Codeforces Round #636 D. Constant Palindrome Sum(差分/好题)
    Codeforces Round #636 C. Alternating Subsequence
    Codeforces Round #636 B. Balanced Array(水)
    Codeforces Round #636 A. Candies(水)
    洛谷P2136 拉近距离(负环判定)
    P2850 [USACO06DEC]Wormholes G(负环判定)
    架构--缓存知识
    集群-架构
    ELK-第二集
    Linux下的I/O复用与epoll详解
  • 原文地址:https://www.cnblogs.com/PingleDay/p/3848277.html
Copyright © 2011-2022 走看看