// 这里出错
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:;
}
Access to the path "G:\photo\gallery\config.xml" is denied.
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.UnauthorizedAccessException: Access to the path "G:\photo\gallery\config.xml" is denied. ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user. To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: [UnauthorizedAccessException: Access to the path "G:\photo\gallery\config.xml" is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +45
System.Xml.XmlTextWriter..ctor(String filename, Encoding encoding) +34
System.Data.DataSet.WriteXml(String fileName, XmlWriteMode mode) +48
System.Data.DataSet.WriteXml(String fileName) +7
Gallery.EditInfo(Object s, EventArgs e) +851
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
dsDataSet.ReadXml(RootPath+"config.xml");
占据了文件的使用权, 因此写入不了, 不过 DataSet 又没有什么 Update的讲法...该 怎么弄呀...
我捉一下虫子再说, 这个 XML 文件我有多个功能需要使用, 可以是某些进程忘记关了...