Path problems with ASP.NET Web Application in 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,C#,C,C++,.net,C#)