473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Path problems with ASP.NET Web Application in C#

I'm writing an ASP.NET Web application in C# that has the following
directory structure:

MyApp\bin\MyApp.dll
MyApp\conf\config.xml
MyApp\webapp.aspx
MyApp\webapp.aspx.cs

ok. The MyApp.dll was created by Visual Studio, webapp.aspx is my
webapp, and webapp.aspx.cs is my codebehind page. I would like to be
able to load and parse the config.xml file when the application
starts. Here is the code I use to open the config file.

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
Nov 18 '05 #1
2 1136
On 16 Nov 2004 15:17:29 -0800 in
microsoft.public.dotnet.framework.aspnet, jo**@bobandjohn.com (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

Nov 18 '05 #2
Thats exactly what I wanted. 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

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Peter Stojkovic | last post by:
I have the following problem: I have a solution in path C:\AAA\CustomerA Now I have a second project: Then I copy everyThing to C:\AAA\CustomerB Bit inside the new project everything is...
2
by: njr | last post by:
Having copied a number of folders from my development PC (XP) to a development server (W2003) and installed them under wwwroot (and created applications in IIS) I have problems when I include the...
4
by: John Smith | last post by:
Hello, I'm not sure if these are the appropriate forums for my question since it is closer to about Visual Studio 2005 than it is about .NET framework. So please pardon me and direct me to a...
34
by: Ben Sizer | last post by:
I've installed several different versions of Python across several different versions of MS Windows, and not a single time was the Python directory or the Scripts subdirectory added to the PATH...
13
by: Shawn | last post by:
I need to get the path to my program after it has been installed. In other words, I want to be able to run a separate application that gets the path to the other apps app.config file. This needs to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.