Allan Macmillan
Allan Macmillan

Reputation: 1491

Accessing Local file from Web Site in VS2013

I have a simple Web Application created in Visual Studio. I simply want to access an XML file that I have added to the package.

This is the hierarchy

Root---index.aspx
  ¦----myxml.xml

but whenever i reference myxml.xml in the c# code for my index page, I get a file not found error?

Upvotes: 0

Views: 31

Answers (1)

Bayeni
Bayeni

Reputation: 1046

Try Server.Path:

var doc = XElement.Load(Server.MapPath("~/myxml.xml"));

Upvotes: 1

Related Questions