currently I m working on web Site of sms
I need to map path of xml file
rather than giving a hardcode path of xml file i m asked to give relative path
the xml file is in same folder from which i m running the program
In web.config i wrote
<add key="XmlConfigPath" value="Xml/Config.xml">
string _xmlConfigPath =string.Empty;
_xmlConfigPath = ConfigurationSettings.AppSettings["XmlConfigPath"].ToString();
_xmlConfigPath = Path.GetFullPath(_xmlConfigPath).ToString();
and path of my xml file is
D:\Deepa\SMS\SMSGateway\SMSGateway\Xml\Config.xml
I get this path currectly but when i try to use this path in following function
public void WriteSMSLog(string Message)
{
double LogFileSizeinKB = Convert.ToDouble(GetMessage("//Config/LogFileSizeinKB", _xmlConfigPath)) * 1000;
}
public string GetMessage(string nodeVal, string filePath)
{
string messageVal;
if (nodeVal != null)
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode xmlNode;
XmlNodeList xmlNodeList;
xmlDoc.Load(filePath);
xmlNodeList = xmlDoc.SelectNodes(nodeVal);
xmlNode = xmlNodeList.Item(0);
messageVal = xmlNode.ChildNodes.Item(0).InnerText.ToString();
return messageVal;
}
}
Input string was not in a correct format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.