我是 C# 新手,我正在使用新字段更新 xml 数据。这些字段未在我的 xml 文件中更新。在我的应用程序中显示已成功更新,但在 xml 文件中我没有找到任何修改...
#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