`

Path problems with ASP.NET Web Application in C#

    博客分类:
  • C#
阅读更多
On 16 Nov 2004 15:17:29 -0800 in
microsoft
.public.dotnet.framework.aspnet, (John
Hite) wrote:

>XmlTextReader xmlReader= new
>XmlTextReader(@"C:\WebApp\conf\config.xml");
>
>Now...This works fine, but I would like to make it so that I don't
>have a hard coded path to the config file. I would like to be able to
>just say
>
>XmlTextReader xmlReader= new XmlTextReader(@"conf\config.xml");
>
>for example and be able to read the file, but this doesn't work.
>whenever I do this I get an error message:
>
>Could not find file "C:\WINDOWS\system32\conf\config.xml".
>
>
>Any suggestions?
>
>Thanks

Check out the methods in the Server class. The following might be what
you want:

string sPath = HttpContext.Current.Server.MapPath(@"conf\config.x ml");
XmlTextReader xmlReader= new XmlTextReader(sPath);

Roger
分享到:
评论

相关推荐

    ASP.NET Core: Cloud-ready, Enterprise Web Application Development

    ASP.NET Core: Cloud-ready, Enterprise Web Application Development by Mugilan T. S. Ragupathi English | 9 Jun. 2017 | ASIN: B072KDVHCS | 1414 Pages | AZW3 | 36.34 MB Create fast, scalable, and high-...

    Migrating to .NET: A Pragmatic Path to Visual Basic .NET, Visual C++ .NET, and ASP.NET

    Migrating to .NET: A Pragmatic Path to Visual Basic .NET, Visual C++ .NET, and ASP.NET Find out how to migrate your legacy software to the powerful Microsoft .NET framework Provides for a complete,...

    asp.net不需要iis也能运行网站 (c#程序 ntbl)

    利用VS调试网站时候自带的Asp.net development server来代替IIS一部分的功能 使用方法: 1.将网站放到WebSite里面就可以执行了 2.或者设置网站目录 phycical path的指向 源代码都包含在内,你直接可以改装,随项目...

    asp.net实现在线查看(预览)pdf,ppt,word,excel文件.rar

    string docExtendName = System.IO.Path.GetExtension(sourceDoc).ToLower(); bool result = false; if (docExtendName == ".pdf") { //pdf模板文件 string tempFile = Path.Combine(fileDire, "temppdf.html"...

    ASP.NET从客户端中检测到有潜在危险的request.form值的3种解决方法

    主要介绍了ASP.NET从客户端中检测到有潜在危险的request.form值的3种解决方法,这是ASP.NET开发中一个比较常见的经典的问题,需要的朋友可以参考下

    《.NET实践之旅 C#篇》黄凯波著

    本书针对因工作等需要使用c#(.net framework)来完成软件项目的人群,可供c#编程人员参考,也可作为大中专院校使用c#进行编程课程的教材。 目录 Chapter 01工程开始(ProjectKickoff) 1.1 一个工作上的小问题 1.2 ...

    Functional Programming in C#.pdf

    Functional Programming in C# leads you along a path that begins with the historic value of functional ideas. Inside, C# MVP and functional programming expert Oliver Sturm explains the details of ...

    ASP.NET的网页代码模型及生命周期

    q designer.cs页文件:用来为页面的控件做初始化工作,一般只有ASP.NET应用程序(Web Application)才有。 ASP.NET页面中包含两种代码模型,一种是单文件页模型,另一种是代码隐藏页模型。这两个模型的功能完全一样...

    ASP.NET4高级程序设计第4版 带目录PDF 分卷压缩包 part1

    ASP.NET 4高级程序设计(第4版)》【原版书为:Pro ASP.NET 4 in C# 2010】是ASP.NET领域的鸿篇巨制,全面讲解了ASP.NET4的各种特性及其背后的工作原理,并给出了许多针对如何构建复杂、可扩展的网站从实践中得出的...

    ASP.NET4高级程序设计(第4版) 3/3

     《ASP.NET 4高级程序设计(第4版)》是ASP.NET领域的鸿篇巨制,全面讲解了ASP.NET4的各种特性及其背后的工作原理,并给出了许多针对如何构建复杂、可扩展的网站从实践中得出的建议。书中还深入讲述了其他ASP.NET图书...

    解决ASP.NET AJAX在frame及iframe中跨域访问的问题

    <asp:ScriptReference Name="MicrosoftAjax.js" ScriptMode="auto" Path="~/ScriptLibrary/System.Web.Extensions/1.0.61025.0/MicrosoftAjax.js" /> </asp:ScriptManager> 2、修改MicrosoftAjax.debug.js 删除...

    ASP.NET Night Words

    第1章 asp.net介绍 2 1.1 xhtml语言 2 1.2 静态网页 3 1.3 动态网页 3 1.4 iis的安装和配置 3 1.5 asp.net开发的预备知识 4 1.5.1 asp.net简介 4 1.5.2 在iis上配置asp.net 4 1.5.3 visual studio版本与 ...

    asp.net 文件夸域名传输带进度条

    <script type="text/C#" runat="server"> BinaryReader ms; UploadInfo uploadInfo = null; protected void Page_Load(object sender, EventArgs args) { if (this.IsPostBack) { uploadInfo = this....

    ASP.NET编程词典个人版

    请到这里下载 原版官方安装文件进行复制安装,完成后 使用我提供的破解版替换原版程序即可使用. https://pan.baidu.com/s/1i36CidJ#list/path=/

    .NET开源的微型Web框架Nancy.zip

    使用Nancy和Simple.Data两个轻量级的框架打造一个分布式开发系统(一)Frictionless .NET Web App Development with NancyFrictionless .NET Web App Development with Nancy Part II - Introducing a View ...

    三种ASP.NET读取Excel文件的方法浅析(含完整代码)

    一、ASP.NET读取Excel文件方法一:采用OleDB读取Excel文件: 把Excel文件当做一个数据源来进行数据的读取操作,实例如下: 1. public DataSet ExcelToDS(string Path) 2. { 3. string strConn = "Provider=Microsoft...

    基于 ASP .net + access 的个人博客系统 源码

    云枫博客系统是由云枫工作室独立开发的一个博客系统,系统环境:asp.net 2.0 +access 开发语言 C#.net。 使用步骤: 1.解压源代码压缩包,然后把源代码上传到服务器空间上(注:服务器空间需支持.net2.0,文件可写...

    Programming in C#: Exam 70-483 (MCSD) Guide

    最新微软C#资格认证考试指南,包括C#8 ...basics of C# and .NET Framework in the first three chapters of the book. To get the most value out of the book, you are expected to have a fair u

Global site tag (gtag.js) - Google Analytics