ASP.net Getting the error “Access to the path is denied.” while trying to upload files to my Windows Server 2008 R2 Web server

前端 未结 9 934
失恋的感觉
失恋的感觉 2020-11-28 04:51

I have an asp.net webapplication that uploads files to a specific folder on the Web server. locally everything works fine, but when I deploy the application to the Webserver

9条回答
  •  隐瞒了意图╮
    2020-11-28 05:23

    I know this is late to the game, but I wanted to share in case it helps someone.

    Your exact situation may not apply, however I had a similar situation and setting the File attribute helped.

    Try to set the File attribute to Normal:

    var path = Server.MapPath("~/App_Data/file.txt");
    File.SetAttributes(path, FileAttributes.Normal);
    System.IO.File.WriteAllText(path, "Hello World");
    

    I hope this helps someone.

提交回复
热议问题