由于网站需要在半夜自动生成静态页面,所以就用Thread实现定时生成~在本地可以正常生成,但是在服务器上确报System.UnauthorizedAccessException: Access to the path 'D:\index.html' is denied错误~
百度上说是由于权限问题,但是生成的方法如果是通过按钮点击事件触发在服务器上是可以正常生成的~为什么使用线程会没有权限?

解决方案 »

  1.   

    D盘写权限设为Everyone,
    还有不要用Thread,要用Windows服务
      

  2.   

    你生成的这个文件,或者访问的文件,一定要包含在你的iis 你的网站的目录下,否则肯定没有权限的你网站的权限肯定只有在它的目录以下才能够有权限的哈!
      

  3.   

    解决了~是因为线程操作需要添加身份认证
    System.Security.Principal.WindowsIdentity obj = System.Security.Principal.WindowsIdentity.GetCurrent();
    System.Security.Principal.WindowsIdentity wi = (System.Security.Principal.WindowsIdentity)obj;
                System.Security.Principal.WindowsIdentity.Impersonate(wi.Token); //模拟用户身份权限
      

  4.   

    此类工作应交给 windows service