Monday, 4 January 2016

XML : issues on xml file present in a set up project

I'm using an xml file to find whether the user is first time user or not for that i written the code like this

  <?xml version="1.0" encoding="utf-8"?>  <UserFirstDetails>  <IsFirstTime>True</IsFirstTime>  <ProductOrderNum></ProductOrderNum>  <Drive></Drive>  </UserFirstDetails>    

in form i written the code like this

  string filePath1 = Application.StartupPath;  string org1 = filePath1 + "\\Input\\UserFirstDetails.xml";  UsrDetails.Load(org1);  XmlNode NdeFirst= UsrDetails.SelectSingleNode("UserFirstDetails/IsFirstTime");  FirstTime = NdeFirst.InnerText;   if (FirstTime == "True")   {     NdeFirst.InnerText = "False";       XmlNode productnum = UsrDetails.SelectSingleNode("UserFirstDetails/ProductOrderNum");     productnum.InnerText = 1234567;        XmlNode drivetag = UsrDetails.SelectSingleNode("UserFirstDetails/Drive");      drive =C;       FileInfo fp = new FileInfo(org1);     fp.Attributes = FileAttributes.Normal;       UsrDetails.Save(org1);  }    

Its working fine for me when i installed the application for first time but when i did uninstall and again reinstall the application i'm getting an xml as

  <?xml version="1.0" encoding="utf-8"?>  <UserFirstDetails>  <IsFirstTime>False</IsFirstTime>  <ProductOrderNum>1234567</ProductOrderNum>  <Drive>C</Drive>  </UserFirstDetails>    

instead of original

   <?xml version="1.0" encoding="utf-8"?>   <UserFirstDetails>   <IsFirstTime>True</IsFirstTime>   <ProductOrderNum></ProductOrderNum>   <Drive></Drive>   </UserFirstDetails>    

Input folder properties are

   Always create-true   condition -   Transitive-False    

No comments:

Post a Comment