sathish ranga

sathish ranga

  • NA
  • 4
  • 15.3k

C# and xml Updation

Oct 23 2012 3:41 AM
I am new to C# i am updating xml Data with new fields. Those fields are not updated in my xml file. In my Application it is showing Updated successfully, but it in xml file i didn't find any modifications...

        #region UpdateCountry method defination
        public void UpdateCountry()
        {
            Image myimg = Image.FromFile(_strLargePath);
            Bitmap myBitmapLarge = new Bitmap(myimg, 64, 64);

            string strFileLarge = string.Format(@"..\..\imageLarge\{0}", Path.GetFileName(_strLargePath));

            //Store Large Image File In Desire Folder
            myBitmapLarge.Save(strFileLarge);

           //Convert those image into 40 * 40 format
           Bitmap myBitmapSmall = new Bitmap(myimg, 40, 40);
           //store it into Desired Small Image folder

           string strFileSmall = string.Format(@"..\..\imageSmall\{0}", Path.GetFileName(_strLargePath));     

            myBitmapSmall.Save(strFileSmall);
            dsXMlData.Tables[0].DefaultView.RowFilter = string.Format("Name='{0}'", txtCountryName.Text);


            string[] strColArr = new string[] { "CapitalCity", "Currency", "Population", "NatLanguage", "LargeImgPath", "SmallImgPath"};

            string[] strValArr = new string[]

          {txtCapitalCity.Text,txtCurrency.Text,txtPopulation.Text,
               txtLangualge.Text,strFileLarge,strFileSmall};
            DataRow drTemp = dsXMlData.Tables[0].DefaultView.ToTable().Rows[0];
            //Updation Starts here
            drTemp.BeginEdit();

            for (int intindex = 1; intindex < strColArr.Length; intindex++)
            {
                drTemp[strColArr[intindex]] = strValArr[intindex];
            }
            drTemp.EndEdit();

            dsXMlData.AcceptChanges();
            
            //Updation complete

            dsXMlData.WriteXml(@"..\..\Countries.xml");

            MessageBox.Show("Updated Successfully");
           // LoadXMlData();
        }
        #endregion