I am loading an xml file from my applicatin:
XDocument.Load(HttpContext.Current.Server.MapPath("/") + "XMLMetadata\\Actions.1.xml");
In the dev environment it is working fine.
But After I deploy the application, the system cannot find it.
this is the error:
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\inetpub\wwwroot\XMLMetadata\Actions.1.xml'.
the file was deployed to
C:\inetpub\wwwroot\MyApp\XMLMetadata\Actions.1.xml
and not to:
C:\inetpub\wwwroot\XMLMetadata\Actions.1.xml
ASP .NET 4 MVC APPLICATION What am I missing?
It's difficult to say what exact framework and base class you are working here, but I'm guessing ASP.NET. If so, you may want to have a look at Control.ResolveUrl()
.
Then, you should get something like the following instead of your Load()
call.
XDocument.Load(this.ResolveUrl("~/XMLMetadata\\Actions.1.xml"));