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

    Server.MapPath用法

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

    42110编辑于 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(“../”) 注:获得所在页面的上级目录。 所以在线程调用方法,方法中类里面的System.Web.HttpContext.Current.Server.MapPath() 获取不到对象。

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

    Server.MapPath()用法

    Server.MapPath()的全名是System.Web.HttpContext.Current.Server.MapPath()。 Server.MapPath(“”) :返回当前页面所在的物理文件路径 Server.MapPath(“/”) :返回应用程序根目录所在的物理文件路径 Server.MapPath(“./”) :返回当前页面所在的物理文件路径 Server.MapPath(“../”):返回当前页面所在的上一级的物理文件路径 Server.MapPath(“~/”):返回应用程序的虚拟目录(路径) Server.MapPath(“~”):返回应用程序的虚拟目录 用法: 1.Server.MapPath(“/”) 应用程序根目录所在的位置 如 C:\Inetpub\wwwroot\ 2.Server.MapPath(“./”) 表示所在页面的当前目录 ( 注:等价于Server.MapPath(“”) 返回 Server.MapPath(“”)所在页面的物理文件路径) 3.Server.MapPath(“../”)表示上一级目录 4.Server.MapPath

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

    Server.MapPath 的使用方法

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

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

    在类中如何使用 Server.MapPath

    直接在类中使用 Server.MapPath 会出现错误,这是由于类中不能直接使用 System.Web.UI.Page 的非静态函数造成的。 方法一、为类增加继承 class CFoo : System.Web.UI.Page 方法二、利用上下文直接使用 System.Web.HttpContext.Current.Server.MapPath 如果我们引入名称空间 System.Web 了,则可以省略为 HttpContext.Current.Server.MapPath。 其实这里并不是只限于 Server.MapPath,还可以这样使用 Server 类的其它属性与方法,比如:Server.HtmlEncode(注意大小写)。

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

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

    :读取文本内容           * 参     数:Path:文件路径           * 调用示列:           *            string Path = Server.MapPath ("Default2.aspx");                *            string NewFile = Server.MapPath("Default3.aspx");            /说明.txt");               *             string NewFile = Server.MapPath("http://www.cnblogs.com/说明.txt OrignFolder:当前目录,NewFloder:新目录           * 调用示列:           *            string orignFolder = Server.MapPath ("test/");             *            string aimPath = Server.MapPath("test1/");           *            

    1.2K10发布于 2018-09-18
  • 来自专栏晓晨的专栏

    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 2、Server.MapPath("./") 注:获得所在页面的当前目录,等价于Server.MapPath("")。 3、Server.MapPath("../") 注:获得所在页面的上级目录。 4、Server.MapPath("~/") 注:获得当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置,如C:\Inetpub\wwwroot\Example\。

    2.3K30发布于 2018-06-22
  • 来自专栏葡萄城控件技术团队

    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.9K51发布于 2018-01-10
  • 来自专栏全栈程序员必看

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

    = Server.CreateObject(“Scripting.FileSystemObject”) Set objCountFile = objFSO.OpenTextFile(Server.MapPath = Server.CreateObject(“Scripting.FileSystemObject”) Set objCountFile = objFSO.OpenTextFile(Server.MapPath ,tempcnt set fso = server.CreateObject(“scripting.filesystemobject”) if not fso.fileExists(server.mappath (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

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

    .NET 使用OLEDB导入Excel数据

    FileName = "App_Data/" + Path.GetFileName(fuload.FileName); if(File.Exists(Server.MapPath (FileName))) { File.Delete(Server.MapPath(FileName)); } fuload.SaveAs(Server.MapPath(FileName)); //HDR=Yes,这代表第一行是标题,不做为数据使用 '"; string connstr2007 = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath conn.Close(); //删除服务器里上传的文件 if(File.Exists(Server.MapPath

    1.3K20编辑于 2022-02-15
  • 来自专栏阿林前端开发攻城狮

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

    Encoding code = Encoding.GetEncoding("gb2312"); string htmlfilename = HttpContext.Current.Server.MapPath Encoding code = Encoding.GetEncoding("gb2312"); string temp = HttpContext.Current.Server.MapPath 则创建文件,并追加文件 * 参 数:Path:文件路径,Strings:文本内容 * 调用示列: * string Path = Server.MapPath /说明.txt"); * string NewFile = Server.MapPath("../.. * 参 数:srcPath:原始路径,aimPath:目标文件夹 * 调用示列: * string srcPath = Server.MapPath("test

    1.2K20发布于 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

    86720编辑于 2022-10-29
  • 来自专栏跟着阿笨一起玩NET

    C#操作XML方法汇总

    XmlDocument xml=new XmlDocument(); //导入指定xml文件 xml.Load(path); xml.Load(HttpContext.Current.Server.MapPath node.Attributes["id"].Value; //获取指定节点中的文本 string content=node.InnerText; //保存XML文件 string path=Server.MapPath ("~/file/bookstore.xml"); xml.Save(path); //or use :xml.Save(HttpContext.Current.Server.MapPath("~/file >58.3</price> </Node> </Employees> 方法二: XmlTextWriter xmlWriter; string strFilename = Server.MapPath price> </Node> </Employees> 2,添加一个结点: XmlDocument xmlDoc=new XmlDocument(); xmlDoc.Load(Server.MapPath

    3.6K10发布于 2018-09-18
  • 来自专栏Java架构师必看

    制作最清晰缩略图的完整类(VB.NET版)

    =====================================         vPicFile.PostedFile.SaveAs(HttpContext.Current.Server.MapPath =========================         PicMax = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath () & ".png"                 vPicMax = PicMax                 PicMax.Save(HttpContext.Current.Server.MapPath vPicMax.Dispose()                 PicMax = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath =========================================         GetMinPic(PicMax).Save(HttpContext.Current.Server.MapPath

    65540发布于 2021-03-22
  • 来自专栏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 { //api/values public string Get() { return System.Web.Hosting.HostingEnvironment.MapPath

    64220编辑于 2023-08-30
  • 来自专栏Java架构师必看

    操作文件系统

    File类的CreateText方法返回一个StreamWriter 在创建StreamWriter 之后,可以调用它的Write方法将文本写到文件中    sw=File.CreateText (MapPath sender, System.EventArgs e)   {    //读文本    StreamReader sr;    //判断路径下文件是否存在    if(File.Exists (MapPath ("ok.txt")))    {     sr=File.OpenText (MapPath("ok.txt"));     TextBox1.Text =sr.ReadLine ();     System.EventArgs e)   {    //写二进制文件    BinaryWriter bw;       //创建一个二进制文件    FileStream fs=new FileStream (MapPath System.EventArgs e)   {    //读二进制文件    BinaryReader br;    string str="";    FileStream fs=new FileStream (MapPath

    53930发布于 2021-03-22
  • 来自专栏小语雀网

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

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

    2.5K30编辑于 2022-05-06
  • 来自专栏css小迷妹

    asp.net下载文件几种方式

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

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

    XmlDocument使用

    private void LoadXml() { xmlDoc=new XmlDocument(); xmlDoc.Load( Server .MapPath el.AppendChild(xesub2); xmldocSelect.AppendChild(el); xmlDoc.Save(Server.MapPath } break; } } xmlDoc.Save(Server.MapPath 全部 内容 break; } } xmlDoc.Save(Server.MapPath

    63920编辑于 2022-06-28
  • 来自专栏技术博客

    一步一步学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

    79820发布于 2018-09-11
领券