Finding Exact Path From Server

Posted by Shoyebaziz123 under ASP.NET on 1/29/2010 | Views : 1089 | Status : [Member] | Replies : 4
Hi All,
I have uploaded my project on server.. in my application i have set a path for making an xml file instance is

str = Server.MapPath("XMLFile\ITR3.xml")

but when running on server it through an error of

' C:\whb\Sites\20614\Web\XMLFile\ITR.xml'

then how to set server path

thanks




Responses

Posted by: Raja on: 1/29/2010 [Member] Starter

Up
0
Down
Use

str = Server.MapPath("~/XMLFile\ITR3.xml") 


~ is used to direct the application t use the path from the root of the application.

Thanks

Regards,
Raja, USA

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sagarp on: 1/29/2010 [Member] Bronze

Up
0
Down
Hi

str = Server.MapPath("~/XMLFile/ITR3.xml")


thanks
sagarp

Thanks
SagarP
http://www.emanonsolutions.net
http://emanonsolutions.blogspot.com/

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 1/29/2010 [Member] Bronze

Up
0
Down
Kindly go through this link

http://msdn.microsoft.com/en-us/library/ms178116.aspx

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: RtpHarry on: 1/30/2010 [Member] [MVP] Bronze

Up
0
Down
Yeah it should be all forward slashes because you are mapping a url to a file path but I think it will probably work with both kinds of slashes.

That article you posted is good Nishithraj

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response