Path to XML file in DataSet

  • Thread starter Thread starter grzegorz.gazda
  • Start date Start date
G

grzegorz.gazda

I am using XML as data store for my website. Then I load it into
DataSet. The path for the file is sPath = "XMLData.xml". When website
read the file it looks for it in c:\Windows\System32 instead of the
location where website files are. When I was trying to use path as URL
(sPath = "http://website/XMLData.xml") I got an error.

How to use relative path for the XML file, and to put it the same
folder or sub folder as the other files which belong to website.
 
If you put the file in the application's root directory, use
Request.PhysicalApplicationPath:
fileName = Request.PhysicalApplicationPath + "\\" + "XMLData.xml";

If you put the file in a subfolder, use MapPath method:
fileName = MapPath(subfolderName) + "\\" + "XMLData.xml";

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
If you're using VS2005, make sure you test
with local deployment
vs
IIS deployment.

When you deploy to production IIS, you don't want any surprises, because
you've been developing "casino style" locally.
 
Back
Top