首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏全栈程序员必看

    Server.MapPath用法

    Server.MapPath的使用方法了,下面记录一下,以备后用: 总注:Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径 1、Server.MapPath(“/”) 2、Server.MapPath(“./”) 注:获得所在页面的当前目录,等价于Server.MapPath(“”)。 3、Server.MapPath(“../”) 注:获得所在页面的上级目录。 4、Server.MapPath(“~/”) 注:获得当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置,如C:\Inetpub\wwwroot\Example\。

    40210编辑于 2022-09-14
  • 来自专栏全栈程序员必看

    Server.MapPath相关

    如果你从Page类继承的类中执行这条语句,才可以简单地使用 DataBase = Server.MapPath(“data.mdb”); 否则写全命名空间:System.Web.HttpContext.Current.Server.MapPath (); 总注:Server.MapPath获得的路径都是服务器上的物理路径,也就是常说的绝对路径 1、Server.MapPath(“/”) 注:获得应用程序根目录所在的位置,如 C:\Inetpub 2、Server.MapPath(“./”) 注:获得所在页面的当前目录,等价于Server.MapPath(“”)。 3、Server.MapPath(“../”) 注:获得所在页面的上级目录。 4、Server.MapPath(“~/”) 注:获得当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置,如C:\Inetpub\wwwroot\Example\。

    48620编辑于 2022-09-14
  • 来自专栏全栈程序员必看

    Server.MapPath()用法

    Server.MapPath(“”) :返回当前页面所在的物理文件路径 Server.MapPath(“/”) :返回应用程序根目录所在的物理文件路径 Server.MapPath(“./”) :返回当前页面所在的物理文件路径 Server.MapPath(“../”):返回当前页面所在的上一级的物理文件路径 Server.MapPath(“~/”):返回应用程序的虚拟目录(路径) Server.MapPath(“~”):返回应用程序的虚拟目录 (路径) 说明:对于Server.MapPath()具体返回什么内容,在不同的环境下得到的结果也许并不相同。 (“./”) 返回路径为:E:\wwwroot\company\news Server.MapPath(“/”) 返回路径为:E:\wwwroot Server.MapPath(“../”) 返回路径为:E:\wwwroot\company Server.MapPath(“~/”) 返回路径为:E:\wwwroot\company server.MapPath(request.ServerVariables

    87420编辑于 2022-09-14
  • 来自专栏全栈程序员必看

    Server.MapPath 的使用方法

    Server.MapPath 的使用方法 用法: 1.Server.MapPath (“/”) 应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\ 2.Server.MapPath (“./”) 表示所在页面的当前目录 注:等价于Server.MapPath (“”) 返回 Server.MapPath (“”)所在页面的物理文件路径 3.Server.MapPath (“../” Server.MapPath (“~/”)表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置 如:C:\Inetpub\wwwroot\Example\ 注:等效于Server.MapPath Server.MapPath (” / “)=C:\inetpub\wwwroot\ //站点根目录的路径 Server.MapPath (” ./ “)=D:\Q\web\应用1\ Server.MapPath

    63530编辑于 2022-09-07
  • 来自专栏全栈程序员必看

    在类中如何使用 Server.MapPath

    直接在类中使用 Server.MapPath 会出现错误,这是由于类中不能直接使用 System.Web.UI.Page 的非静态函数造成的。 其实这里并不是只限于 Server.MapPath,还可以这样使用 Server 类的其它属性与方法,比如:Server.HtmlEncode(注意大小写)。

    3.5K30编辑于 2022-09-14
  • 来自专栏跟着阿笨一起玩NET

    C#常用操作类库四(File操作类)

    ("Default2.aspx");                *            string NewFile = Server.MapPath("Default3.aspx");            * 参     数:OrignFile:原始路径,NewFile:新文件路径           * 调用示列:           *             string orignFile = Server.MapPath /说明.txt");               *             string NewFile = Server.MapPath("http://www.cnblogs.com/说明.txt * 参     数:srcPath:原始路径,aimPath:目标文件夹           * 调用示列:           *            string srcPath = Server.MapPath ("test/");             *            string aimPath = Server.MapPath("test1/");           *            

    1.1K10发布于 2018-09-18
  • 来自专栏葡萄城控件技术团队

    ActiveReports 报表应用教程 (16)---报表导出

    ) + "Reports/" + report + ".rdlx")); _reportDef.Report.DataSources[0].DataSourceReference = Server.MapPath ) + "Reports/" + report + ".rdlx")); _reportDef.Report.DataSources[0].DataSourceReference = Server.MapPath ) + "Reports/" + report + ".rdlx")); _reportDef.Report.DataSources[0].DataSourceReference = Server.MapPath ) + "Reports/" + report + ".rdlx")); _reportDef.Report.DataSources[0].DataSourceReference = Server.MapPath pdfExport1.Signature.Stamp.Image = System.Drawing.Image.FromFile(Server.MapPath("..

    2.8K51发布于 2018-01-10
  • 来自专栏全栈程序员必看

    使用FSO修改文件特定内容的函数

    objFSO = Server.CreateObject(“Scripting.FileSystemObject”) Set objCountFile = objFSO.OpenTextFile(Server.MapPath (filename)) then exit function set f = fso.opentextfile(server.mappath(filename),1) if not f.AtEndofStream (filename)) then exit function set f = fso.opentextfile(server.mappath(filename),1) if not f.AtEndofStream (filename)) then exit function set f = fso.opentextfile(server.mappath(filename),8,1) f.write chr(13 (Foldername))=true then else afso.createfolder(server.mappath(foldername)) end if set afso

    2K20编辑于 2022-09-02
  • 来自专栏编程进阶实战

    .NET 使用OLEDB导入Excel数据

    (FileName))) { File.Delete(Server.MapPath(FileName)); } fuload.SaveAs(Server.MapPath(FileName)); //HDR=Yes,这代表第一行是标题,不做为数据使用 系统默认的是YES string connstr2003 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath IMEX=1;'"; string connstr2007 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath (FileName))) { File.Delete(Server.MapPath(FileName));

    1.3K20编辑于 2022-02-15
  • 来自专栏晓晨的专栏

    C#获取根目录的方法集合

    用于App_Data中获取      方法2、Server.MapPath("") 或者Server.MapPath("~/");//返回与Web服务器上的指定的虚拟路径相对的物理文件路径      方法 System.Web.HttpContext.Current.Request.PhysicalApplicationPath 方法2:System.Web.HttpContext.Current.Server.MapPath("./") 总注:Server.MapPath 获得的路径都是服务器上的物理路径,也就是常说的绝对路径 1、Server.MapPath("/") 注:获得应用程序根目录所在的位置,如 C:\Inetpub\wwwroot\。 2、Server.MapPath("./") 注:获得所在页面的当前目录,等价于Server.MapPath("")。 3、Server.MapPath("../") 注:获得所在页面的上级目录。 4、Server.MapPath("~/") 注:获得当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置,如C:\Inetpub\wwwroot\Example\。

    2.3K30发布于 2018-06-22
  • 来自专栏阿林前端开发攻城狮

    C#封装的常用文件操作代码类

    当文件不存时,则创建文件,并追加文件 * 参 数:Path:文件路径,Strings:文本内容 * 调用示列: * string Path = Server.MapPath 函数名称:ReadFile * 功能说明:读取文本内容 * 参 数:Path:文件路径 * 调用示列: * string Path = Server.MapPath ("Default2.aspx"); * string NewFile = Server.MapPath("Default3.aspx"); * /说明.txt"); * string NewFile = Server.MapPath("../.. * 参 数:srcPath:原始路径,aimPath:目标文件夹 * 调用示列: * string srcPath = Server.MapPath("test

    1.1K20发布于 2021-11-02
  • 来自专栏全栈程序员必看

    .NET-OOP:.文件读写与XML

    //关闭文件流 myFs.Close(); l 文件夹创建、移动、删除 //创建文件夹 Directory.CreateDirectory(Server.MapPath(“a”)); Directory.CreateDirectory (Server.MapPath(“b”)); Directory.CreateDirectory(Server.MapPath(“c”)); //移动b到a Directory.Move(Server.MapPath (“b”), Server.MapPath(“a//b”)); //删除c Directory.Delete(Server.MapPath(“c”)); l XML,XML称为可扩展标记语言,是eXtensible

    84820编辑于 2022-10-29
  • 来自专栏DotNet NB && CloudNative

    C#获取根目录实现方法汇总

    AppDomain.CurrentDomain.BaseDirectory txtBox4.Text = AppDomain.CurrentDomain.BaseDirectory; } 效果如下: 3.MVC和WebForm项目 通过Server.MapPath ("/")获取根目录 //WebForm

    <%=Server.MapPath("/") %>

    //Mvc

    @Server.MapPath("/")

    4.WebApi

    60520编辑于 2023-08-30
  • 来自专栏跟着阿笨一起玩NET

    C#操作XML方法汇总

    id=node.Attributes["id"].Value; //获取指定节点中的文本 string content=node.InnerText; //保存XML文件 string path=Server.MapPath xe1.AppendChild(xesub3); root.AppendChild(xe1);//添加到<Employees>节点中 } //保存创建好的XML文档 xmldoc.Save ( Server.MapPath >58.3</price> </Node> </Employees> 2,添加一个结点: XmlDocument xmlDoc=new XmlDocument(); xmlDoc.Load(Server.MapPath </Node> </Employees> 4,修改结点(添加结点的属性和添加结点的自结点): XmlDocument xmlDoc=new XmlDocument(); xmlDoc.Load( Server.MapPath xesub=xmlDoc.CreateElement("flag"); xesub.InnerText="1"; xe.AppendChild(xesub); } xmlDoc.Save( Server.MapPath

    3.5K10发布于 2018-09-18
  • 来自专栏小语雀网

    ASP.NET指定页面转PDF、JPG(插件)

    pdfpath = filename + ".pdf"; Process p = System.Diagnostics.Process.Start(pdf, url + " \"" + Server.MapPath p.WaitForExit(); //下载 FileStream fs = new FileStream(Server.MapPath pdfpath = filename + ".jpg"; Process p = System.Diagnostics.Process.Start(jpg, url + " \"" + Server.MapPath + "\""); p.WaitForExit(); //下载 FileStream fs = new FileStream(Server.MapPath

    2.4K30编辑于 2022-05-06
  • 来自专栏技术、架构与思维

    小技术之异步上传文件

    message = "请选择非空字节的文件" }); } //设置文件保存在服务器上的路径 var path = Server.MapPath private string urlToVirtual(string imagesurl1) { //其实这里的tmpRootDir也等于tmpRootDir=Server.MapPath ("~/"); string tmpRootDir = Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString Request.Files,第二步Server.MapPath拿到路径,第三步SaveAs就就可以了。

    1.1K20发布于 2018-09-12
  • 来自专栏css小迷妹

    asp.net下载文件几种方式

    x-zip-compressed"; Response.AddHeader("Content-Disposition", "attachment;filename=z.zip"); string filename = Server.MapPath sender, EventArgs e) { /* using System.IO; */ string fileName ="aaa.zip";//客户端保存的文件名 string filePath=Server.MapPath Button3_Click(object sender, EventArgs e) { string fileName = "aaa.zip";//客户端保存的文件名 string filePath = Server.MapPath Button4_Click(object sender, EventArgs e) { string fileName = "aaa.zip";//客户端保存的文件名 string filePath = Server.MapPath

    2.3K20发布于 2021-11-02
  • 来自专栏菩提树下的杨过

    Asp.Net Mvc中的一些初级问题整理

    public void DeleteData() { using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + Server.MapPath //顺便给个sqlite使用事务的代码 //using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + Server.MapPath DataTable tbl = new DataTable(); using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + Server.MapPath

    1.4K80发布于 2018-01-23
  • 来自专栏技术博客

    一步一步学Linq to sql(六):探究特性

    NorthWindDataContext North = new NorthWindDataContext(); StreamWriter sw = new StreamWriter(Server.MapPath NorthWindDataContext North = new NorthWindDataContext(); StreamWriter sw = new StreamWriter(Server.MapPath NorthWindDataContext ctx = new NorthWindDataContext(); StreamWriter sw = new StreamWriter(Server.MapPath NorthWindDataContext ctx = new NorthWindDataContext(); StreamWriter sw = new StreamWriter(Server.MapPath NorthWindDataContext ctx = new NorthWindDataContext(); StreamWriter sw = new StreamWriter(Server.MapPath

    77020发布于 2018-09-11
  • 来自专栏Java架构师必看

    asp.net 对xml文件的读写,添加,修改,删除操作

    XmlDocument xmlDoc; //load xml file private void LoadXml() { xmlDoc=new XmlDocument(); xmlDoc.Load(Server.MapPath ); xesub2.InnerText="昆明";//设置文本节点 el.AppendChild(xesub2); xmldocSelect.AppendChild(el); xmlDoc.Save(Server.MapPath xn1;//转换类型 if(xe2.Name=="pass")//如果找到 { xe2.InnerText="66666";//则修改 break; } } break; } } xmlDoc.Save(Server.MapPath ="发明") { //xe.RemoveAttribute("name");//删除name属性 xe.RemoveAll();//删除该节点的全部内容 break; } } xmlDoc.Save(Server.MapPath

    2.2K30发布于 2021-03-22
领券