I want to read a xml file from a WCF service.
The xml file, settings.xml is in the same folder as the service exe and the service is hosted as a Windows service.
when the service is accessed by the client the service exe is looking at system32 folder and throws file not found exception
C:\Windows\system32\Settings.xml
Here’s the code which is in a try catch block and a FaultException is thrown which the client catches.
XmlSerializer serializer = new XmlSerializer(_appSettings.GetType());
StreamReader sr = new StreamReader("Settings.xml", Encoding.UTF8);
_appSettings = (SpecialityFinishingSettings)serializer.Deserialize(sr);
sr.Close();
Basically I am trying to read the xml and deserialize it into an object that can be used withing the service.
What do I do to read this file from within the service?
The serivce is installed using InstallUtil.exe
The problem is that “Settings.xml” isn’t found as a file. You need to specify a full path. You can either: