Hi All,
I have a webservice that will contact a SQL database. This database connection string will need to contain a username and password. Ass this password must be changed every 6 months we have decided to keep this data in an xml file on the web service so that it can be dynamically added to the connection string.
So i have the xml file that contains this data:
<pre><AllUsers>
<user>
<ID>ID</ID>
<Password>NewPassword</Password>
</user>
</AllUsers>
and i have the code needed to deserialize this into an existing class called user.
public static List<T> RetrieveFromXML<T>(string filename, string root)
{
List<T> t;
using (FileStream fs = new FileStream(filename, FileMode.Open))
{
XmlSerializer ser = new XmlSerializer(typeof(List<T>), new XmlRootAttribute(root));
t = (List<T>)ser.Deserialize(fs);
}
return t;
}
so to call this function i must put:
List<user> account = RetrieveFromXML<user>(@"AccountDetails.xml","AllUsers");
However i get an error saying the AccountDetails.xml doesnt exist or isnt situated wherever it is looking.
Should this file be an embedded resource? content? and what can i use to get the correct position of this file in the assembly?
Many thanks