I am trying to store an XML file as a project resource so I do not have to hard code any file paths when I compile. I keep on getting an error when I call ReadXML. Any thoughts? If there are better ways of referencing a file without hard coding a path please let me know.
Thanks!
public class XMLLoad
{
public DataSet ds { get; set; }
public string PrimaryKey { get; set; }
public string XLETable
{
get
{
//Returns an XML file
return Properties.Resources.mainXLETable;
}
}
public XMLLoad(string xmlPrimaryKey)
{
this.PrimaryKey = xmlPrimaryKey;
}
public DataSet ReturnXMLFileAsDataSet(string dataTableName)
{
try
{
var reader = XmlReader.Create(XLETable);
var dt = new DataTable(dataTableName);
ds.ReadXml(reader);
dt = ds.Tables[0];
return ds;
}
catch (Exception)
{
throw;
}
}
}