updating XML files on the Web

  • Thread starter Thread starter ShayHk
  • Start date Start date
S

ShayHk

Hello
I created a webSite using a free web hosting space (that supports
asp.net applications).
The website was created with asp.net project
The problem is that I cant update XML files that are placed on the web
site . why?

for example :

fileName = "www.website.com/xmlFile.xml";
try {
doc = new XmlDocument();
doc.Load( fileName );
....
doc.Save( fileName ); // throw Exception !!! why ?
}

the excption message is : "URI formats are not supported."
How can I handle this?
 
Hi,
Hello
I created a webSite using a free web hosting space (that supports
asp.net applications).
The website was created with asp.net project
The problem is that I cant update XML files that are placed on the web
site . why?

for example :

fileName = "www.website.com/xmlFile.xml";
try {
doc = new XmlDocument();
doc.Load( fileName );
...
doc.Save( fileName ); // throw Exception !!! why ?
}

the excption message is : "URI formats are not supported."
How can I handle this?

You must save the file using the absolute path. You should be able to
get the absolute path from your provider. Alternatively, you can try
using MapPath:

fileName = "xmlFile.xml";
// "this" refers to the Page.
doc.Save( this.MapPath( fileName ) );

// if you're not in a Page, you can also use
doc.Save( HttpServerUtility.MapPath( fileName ) );

HTH,
Laurent
 
Back
Top