Why is access to the path denied?

前端 未结 29 1541
刺人心
刺人心 2020-11-22 15:25

I am having a problem where I am trying to delete my file but I get an exception.

if (result == \"Success\")
{
     if (FileUpload.HasFile)
     {
         t         


        
29条回答
  •  借酒劲吻你
    2020-11-22 15:44

    I also had the problem, hence me stumbling on this post. I added the following line of code before and after a Copy / Delete.

    Delete

    File.SetAttributes(file, FileAttributes.Normal);
    File.Delete(file);
    

    Copy

    File.Copy(file, dest, true);
    File.SetAttributes(dest, FileAttributes.Normal);
    

提交回复
热议问题