Getting Folder Path From Server

Posted by Shoyebaziz123 under ASP.NET on 7/2/2010 | Views : 2705 | Status : [Member] | Replies : 3
Hi All,
I have uploaded my application on domain, in my application there s a folder naming XMLFile in this folder i have an xml File to which i am getting refrence like this


str = Server.MapPath("~XMLFile\SampleITR1_2010-11.xml") .............

then after comleting my work have to save that xml in same folder like this

strMessage = Server.MapPath("~XMLFile")
intRandomNumber = RandomGenerator.Next(1, 100)
mXmlDataSet.WriteXml(strMessage & "-ITR1-" & "-" & intRandomNumber & ".Xml")

but there is some error like

Could not find a part of the path 'C:\whb\Sites\20614\Web\~XMLFile\SampleITR1_2010-11.xml'.

then what is going wrong




Responses

Posted by: BangaruBabu on: 7/2/2010 [Member] Starter

Up
0
Down
Hi if it is Under Root Folder

Eg: Let Us Assume Like This

RootFolder= MyProject
SubFolder=MyXMLDir


1)If U Want to Refer RootFolder

string s=Server.MapPath(~/MyProject);

2)If U Want to refer SubFolder

string s1=Server.MapPath(. /MyXMLDir)

3)If U Want To Refer SubFolder In MyXMLDir--Place 2 dots in Server.MapPath() as Follows

string s2=Server.MapPath(../MyXMLDir)




BangaruBabu Pureti
http://bangarubabupureti.spaces.live.com/

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

Posted by: Shoyebaziz123 on: 7/2/2010 [Member] Starter

Up
0
Down
it shows an error


Access to the path 'C:\whb\Sites\20614\Web\XML File Save2010-11-ITR1-XXXXX0000X-63.xml' is denied.

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

Posted by: Muhilan on: 7/5/2010 [Member] Starter

Up
0
Down
i thing you dont have permission to override the existing file, check file rights in domain

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

Login to post response