日期:2014-05-18  浏览次数:21125 次

System.UnauthorizedAccessException,异常无法解决
对路径“D:\asp.net\文档管理系统”的访问被拒绝。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.UnauthorizedAccessException: 对路径“D:\asp.net\文档管理系统”的访问被拒绝。 

ASP.NET 未被授权访问所请求的资源。请考虑授予 ASP.NET 请求标识访问此资源的权限。ASP.NET 有一个在应用程序没有模拟时使用的基进程标识(通常,在 IIS 5 上为 {MACHINE}\ASPNET,在 IIS 6 上为网络服务)。如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。 

要将 ASP.NET 访问权限授予某个文件,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加适当的用户或组。突出显示 ASP.NET 帐户,选中所需访问权限对应的框。

源错误: 


行 491: try
行 492: { 
行 493: sourceFile.PostedFile.SaveAs(destinationFilePath);
行 494: return true;
行 495:  
 

源文件: d:\asp.net\巨涛文档管理系统\App_Code\FileManager.cs 行: 493 

堆栈跟踪: 


[UnauthorizedAccessException: 对路径“D:\asp.net\文档管理系统”的访问被拒绝。]
  System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7716639
  System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy) +1162
  System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +61
  System.IO.FileStream..ctor(String path, FileMode mode) +55
  System.Web.HttpPostedFile.SaveAs(String filename) +261
  FileManager.UpLoadFile(FileUpload sourceFile, String destinationFilePath) in d:\asp.net\巨涛文档管理系统\App_Code\FileManager.cs:493
  NewDocmentSign.UploadFile_Click(Object sender, EventArgs e) in d:\asp.net\巨涛文档管理系统\NewDocmentSign.aspx.cs:60
  System.Web.UI.WebControls.Button.OnClick(EventArgs e) +126
  System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +135
  System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +39
  System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +37
  System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +87
  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4178

 


--------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.3625; ASP.NET 版本:2.0.50727.3618 


而且,对 D:\asp.net\文档管理系统权限设置
--------------------------------------------------
configuration>
  
<appSettings/> 
  
<connectionStrings/>
<system.web>
  <authentication mode="Windows"/>
  <identity impersonate="true"/>

  <!-- 
  设置 compilation debug="true" 将调试符号插入
  已编译的页面中。但由于这会 
  影响性能,因此只在开发过程中将此值 
  设置为 true。
  -->
  <compilation debug="true">
<assemblies>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Management.Instrumentation, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
<!--
  通过 <authentication> 节可以配