双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

使用 DataSet 从 XML文件 读取数据, 那我怎么保存更改...更新读取的XML文件

btbtd btbtd 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

// 这里出错
dsDataSet.WriteXml(RootPath+"config.xml");

//---------------------------------------------------

public void EditInfo(Object s, EventArgs e)
{
String Username=System.Web.HttpContext.Current.Request.Form["Username"]+"";
String Password=System.Web.HttpContext.Current.Request.Form["Password"]+"";
//Password=md5(Password);
String CheckCode=System.Web.HttpContext.Current.Request.Form["CheckCode"]+"";
String CheckCodeSession=System.Web.HttpContext.Current.Session["GalleryCheckCode"]+"";

if(debug)
{
System.Web.HttpContext.Current.Response.Write("<li/>"+Username);
System.Web.HttpContext.Current.Response.Write("<li/>"+Password);
System.Web.HttpContext.Current.Response.Write("<li/>"+CheckCode);
System.Web.HttpContext.Current.Response.Write("<li/>"+CheckCodeSession);
System.Web.HttpContext.Current.Response.Write("<hr/>");
}

if(CheckCode!=CheckCodeSession)
{
Message("验证码错误!");
goto Error;
}

if(Username=="")
{
Message("用户名不能为空!");
goto Error;
}

Finished:;

RootPath=System.Web.HttpContext.Current.Server.MapPath(".");
if(!RootPath.EndsWith("\\"))RootPath+="\\";
DataSet dsDataSet=new DataSet();
DataTable dtConfig=new DataTable();

dsDataSet.ReadXml(RootPath+"config.xml");
dtConfig=dsDataSet.Tables["Config"];

dtConfig.Rows[0]["Username"]=Username;

if(Password!="")
{
dtConfig.Rows[0]["Password"]=md5(Password);
}

// 这里出错
dsDataSet.WriteXml(RootPath+"config.xml");

dsDataSet.Dispose();
dtConfig.Dispose();

Error:;

goto End;

End:;
}
...全文
评论 7
收藏 已收藏
分享
返回顶部
btbtd
.NET社区 62,274 成员 668,968 内容