Why is access to the path denied?

前端 未结 29 1089
刺人心
刺人心 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:43

    This is an old issue, but I ran into it while searching. Turns out that I was missing the actual filename component in the save path for SaveAs...

    string uploadPath = Server.MapPath("~/uploads");
    file.SaveAs(uploadPath); // BAD
    file.SaveAs(Path.Combine(uploadPath, file.FileName)); // GOOD
    

提交回复
热议问题