Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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">

C#
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

C#
public void WriteSMSLog(string Message)
       {


C#
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);//at this line i get following exception
                    xmlNodeList = xmlDoc.SelectNodes(nodeVal);
                    xmlNode = xmlNodeList.Item(0);

                    messageVal = xmlNode.ChildNodes.Item(0).InnerText.ToString();
                    return messageVal;
}
                }


CSS
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.
Posted
Updated 9-Aug-11 19:42pm
v2

1 solution

It seems you have no idea how to do any of your project, or to read any sort of error message. Your input string was apparently not in the correct format. You should consider telling us what line has the error, and what the input string is, if you want us to do your job for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900