string TempPath = "D:\\wwwroot\\a.txt";
if (File.Exists(Server.MapPath(TempPath)))
{
 File.Delete(Server.MapPath(TempPath));
}//无报错,但是无法删除
//测试用↓string TempPath = "D:\\wwwroot\\a.txt";
aaa.Text = TempPath;
if (File.Exists(Server.MapPath(TempPath)))
{
 File.Delete(Server.MapPath(TempPath));
 bbb.Text = TempPath;
}
ccc.Text = TempPath;//aaa能取得值,bbb,ccc都没值!//请教高手
//注:我权限已经EveryOne完全控制
//顺便问一下:支持IO操作的最低权限是什么啊??

解决方案 »

  1.   

    string TempPath = "D:\\wwwroot\\a.txt";
    aaa.Text = TempPath;
    if (File.Exists(TempPath))
    {
     File.Delete(TempPath);
     bbb.Text = TempPath;
    }
    ccc.Text = TempPath;
      

  2.   

    楼上的,Server.MapPath(TempPath)是我的疏忽,
    但是去掉了Server.MapPath问题依旧!顺便问一下:支持IO操作的最低权限是什么啊??我不想设置EveryOne完全控制
      

  3.   

    D:\\wwwroot 已经是根路径了.
      

  4.   

    Exists地用法好像不对!TRY IT
    ===================================
    string TempPath = "D:\\wwwroot\\a.txt";
    FileInfo info=new FileInfo(TempPath);
    if(info.Exists)
    {
    File.Delete(TempPath);
    }
      

  5.   

    多谢各位,问题解决了!顺便问一下:支持IO操作的最低权限是什么啊??我不想设置EveryOne完全控制
      

  6.   

    这个配置确实挺麻烦的,我也没搞懂,建议你去别的区问一下。
    每次上服务器时我也是调成EVERYONE。
      

  7.   

    不用EVERYONE
    只把ASPNET,NetWork Serivce,权限加上,应该就可以了
      

  8.   

    EveryOne完全控制 这样安全性不能保障啊.
      

  9.   

    TO:xray2005(风车车--要飞翔,必须靠自己!) ASPNET,NetWork Serivce 加什么权限呢?
      

  10.   

    ASPNET账户添加administrator的权限!!