ASP.NET获取各级目录Server.MapPath详解全
Server.MapPath("/") 应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\ 
Server.MapPath("~/")表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置 如:C:\Inetpub\wwwroot\Example\
Server.MapPath("./") 表示所在页面的当前目录 注:等价于Server.MapPath("") 返回 Server.MapPath("")所在页面的物理文件路径 :返回路径为:E:\wwwroot\company\news
Server.MapPath("../")表示上一级目录 :返回路径为:E:\wwwroot\company
App_Code文件夹下 类获取路径 HttpRuntime.AppDomainAppPath : 注:等效于Server.MapPath("~")。
server.MapPath(request.ServerVariables("Path_Info")),Request.ServerVariables("Path_Translated") 上面两种方式返回路径为 D:\wwwroot\company\news\show.aspx
Server.MapPath(Request.ApplicationPath);和HttpRuntime.AppDomainAppPath有何区别?
对于:http://localhost/DllTest/DLayer.aspx 
Server.MapPath( ".")---D:\wwwroot\DllTest 
HttpRuntime.AppDomainAppPath---D:\wwwroot\DllTest\ 
一个有最后的'\ ',一个没有
相关推荐
- 
                             
                            asp.net 获取目录下的文件数和文件夹数复制代码 代码如下: int j = 0; protected void Button1_Click(object sender, EventArgs e) { DirectoryInfo dir = new DirectoryInfo(TextBox1.Text.ToString()); Label1.Text = GetAllFiles(dir).ToString(); }GetAllFiles方法为自定义方法,实现遍历整个文件夹文件的方法.代码如下: public int GetAllFi 
- 
                             
                            asp.net 获取指定文件夹下所有子目录及文件(树形)#region 获取指定文件夹下所有子目录及文件(树形) /**************************************** * 函数名称:GetFoldAll(string Path) * 功能说明:获取指定文件夹下所有子目录及文件(树形) * 参 数:Path:详细路径 * 调用示列: * string strDirlist = Server.M 
- 
                             
                            Asp.net获取当前目录的方法小结方法一: string sPath = System.IO.Path.GetDirectoryName(Page.Request.PhysicalPath) 方法二: string sPath = System.Web.HttpContext.Current.Request.MapPath("/") 方法三: string sPath = Page.Server.MapPath("/"); 我推荐使用第二种 
- 
                             
                            Asp.net 获取指定目录下的后缀名为".doc" 的所有文件名和文件路径c#核心代码: 复制代码 代码如下: DirectoryInfo dir = new DirectoryInfo(strPath); foreach (FileInfo fi in dir.GetFiles("*.doc")) { if (fi.FullName.EndsWith(".doc")) // 将 docx 类型的文件过滤掉 { // 这个 fi 就是你要的 doc 文件 Console.WriteLine(fi.Name); } } 
- 
                             
                            Asp.net获取服务器指定文件夹目录文件并提供下载的方法本文实例讲述了Asp.net获取服务器指定文件夹目录文件并提供下载的方法.分享给大家供大家参考.具体实现方法如下: 复制代码 代码如下: string dirPath = HttpContext.Current.Server.MapPath("uploads/"); if (Directory.Exists(dirPath)) { //获得目录信息 DirectoryInfo dir = new DirectoryInfo(dirPath); 
- 
                             
                            asp.net获取网站目录物理路径示例页面后台cs文件的相对网站根目录的路径/view/Atlas 复制代码 代码如下: string rootPath1= Server.MapPath("~"); string rootPath2 = Request.ApplicationPath; string path1 = Server.MapPath("upload"); string path2 = Server.MapPath(""); string path3 = Server.Ma 
- 
                             
                            Asp.Net获取网站截图的实例代码复制代码 代码如下: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form1 : Form { 
- 
                             
                            asp.net 文件路径之获得虚拟目录的网站的根目录string Server.MapPath(string path) 返回与Web服务器上的指定虚拟路径相对应的物理文件路径. Server.MapPath(Request.ServerVariables["PATH_INFO"]) Server.MapPath("/") Server.MapPath("") Server.MapPath(".") Server.MapPath("../") Server. 
- 
                             
                            ASP.NET编程获取网站根目录方法小结本文实例讲述了ASP.NET编程获取网站根目录方法.分享给大家供大家参考,具体如下: 获取网站根目录的方法有几种如: Server.MapPath(Request.ServerVariables["PATH_INFO"]) Server.MapPath("/") Server.MapPath("")//当前代码文件所在的目录路劲 Server.MapPath(".") Server.MapPath("../" 
- 
                             
                            Asp.Net 文件操作基类(读取,删除,批量拷贝,删除,写入,获取文件夹大小,文件属性,遍历目录)复制代码 代码如下: using System; using System.IO; using System.Text; using System.Data; using System.Web.UI; using System.Web.UI.WebControls; namespace ec { /// <summary> /// 文件操作类 /// </summary> public class FileObj : IDisposable { private bool _alre 
随机推荐
- PowerShell计算脚本执行时间的实现方法
- MongoDB的聚合框架Aggregation Framework入门学习教程
- Java基于JavaMail实现向QQ邮箱发送邮件
- java当中的定时器的4种使用方式
- Windows系统下Java连接SQL Server的方法简介
- javascript DOM对象的学习实例代码
- 详解docker容器分配静态IP
- Hibernate4在MySQL5.1以上版本创建表出错 type=InnDB
- node.js中的fs.truncateSync方法使用说明
- CreateKeyWord asp实现的由给定的字符串生成关键字的代码
- C#遍历操作系统下所有驱动器的方法
- VBScript 作用 简单说明
- 在SQLServer上查看SQL语句的执行时间的方法
- java读取csv文件和写csv示例分享
- JS实现全景图效果360度旋转
- Android定时器Timer的停止和重启实现代码
- java 实现最小二叉树堆排序的实例
- Javascript技术技巧大全(五)
- Android编程获取网络连接方式及判断手机卡所属运营商的方法
- c++函数转c#函数示例程序分享
