Click here to Skip to main content
16,012,611 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
currently I m working on web Site of sms
I need to map path of xml file
rather than giving a hardcode path of xml file i m asked to give relative path
the xml file is in same folder from which i m running the program

In web.congig i wrote
<add key="XmlConfigPath" value="../Xml/Config.xml">

C#
string _xmlConfigPath =string.Empty;
_xmlConfigPath = ConfigurationSettings.AppSettings["XmlConfigPath"].ToString();
            _xmlConfigPath = System.Web.HttpContext.Current.Server.MapPath(_xmlConfigPath).ToString();
//at this line i get following exception

CSS
Server Error in '/' Application.
Cannot use a leading .. to exit above the top directory.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Cannot use a leading .. to exit above the top directory.


Same cocept is used in one of our previous programs where above line worked fine
Posted

1 solution

Gee - the error seems clear enough to me. You're trying to use .. to move above the application root. I know you never did that before, because it's not possible. Hence the error message.

The issue is .. in the _xmlConfigPath, it's trying to step above the root folder.
 
Share this answer
 
Comments
Member 8081020 10-Aug-11 1:29am    
will u please elaborate?
what is mean by application root?
the path of xml file is
D:\Deepa\SMS\SMSGateway\SMSGateway\Xml\config.xml

and i m running smsgateway program
I tried to use path.getfullpath()
but it gave me path
D:\Deepa\SMS\Xml\config.xml

which again gave me eror path not found
Christian Graus 10-Aug-11 1:35am    
You're working on a web site. The folder that's at the top of your website, the top folder of your project, is the application root.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900