I feel like I’m missing some configuration in IIS or Global file maybe ?
I want to load an xml file:
var icon = XDocument.Load("/images/body/logos/LogoImageMappings.xml");
When running it fails because it tries to locate the file @ C:\images\body\logos\LogoImageMappings.xml
How can I correctly direct it to Localhost ( or web server when published ) application drive instead of a local c: ?
Thank you.
You have to map the path to the directory where the file resides. Use this:
The
Server.MapPathfunction will map the relative path to the full path of the file on the server, replacing tilde with the right directory (note that the relative path must point to a sub-directory of your web-site directory, for security reasons usually you can’t access anything higher than that).