A very persistant Access To Path Denied Error

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default A very persistant Access To Path Denied Error

    Hi Guys,

    I'm stuck with a terribly persistant "Access to the path *** is denied"
    problem. I'm trying to upload a foile using the file control. The code
    checks if a file of the same name as uploaded exists and if so, attempts to
    delete the file and then uploads the new file.

    Dim myFile As File

    If myFile.Exists(Server.MapPath("..\photos\family\stu dent\" &
    Session("ChildId") & ".jpg")) Then

    myFile.Delete(Server.MapPath("..\photos\family\stu dent\" &
    Session("ChildId") & ".jpg")) ' exception thrown here

    End If

    file1.PostedFile.SaveAs(Server.MapPath("..\photos\ family\
    student\" & Session("ChildId") & ".jpg"))




    However I keep getting the following error "Access to path ** is denied"

    I've given ASP.NET all complete access to the folder where the file is to
    be uploaded. I've even turned on impersonation in the webconfig file and it
    still doesn't work. It makes no sense. I've tried everything an still no
    luck. Any code snippets or suggetsions for this problem would be highly
    appreciated.

    --
    Message posted via [url]http://www.dotnetmonster.com[/url]
    Mohammad Ali via DotNetMonster.com Guest

  2. Similar Questions and Discussions

    1. Access to path is denied...
      I'm trying to test/check contents of a dataset by writing it to an xml file on the server, but get this error above. The suggestion to grant...
    2. Access to path denied
      I have a question. I am running Windows 2003 Server with Framework 1.1. I have an application that has XML config files within it that drive part...
    3. Access to the path is denied
      This is error message I've got. Any suggestion would be appreciated. Server Error in '/WebDirectory' Application. ...
    4. Access to Path is denied
      What account is your webservice running under? aspnet? Does aspnet have access to the directory? Maarten "Eric Levin" <eric@soundsite.com>...
    5. Access to the path ...\\dynamic_images is denied. What Happens???
      I have designed a report that uses the CrystalReportViewer which works fine on my local machine. I created a setup to install Crystal Report in my...
  3. #2

    Default Re: A very persistant Access To Path Denied Error

    Either your application doesn't have write permissions or your application
    (or someother application) is holding a lock on the file. If you don't have
    the perms then enable that directory for write access to the user that your
    ASP.NET app is running as. This is either the local ASPNET account on W2K
    or the Network Service account on W2K3. If it's not this, then some application
    has a lock on the file on the filesystem. From the other parts of your application
    are you making sure to call Close or Dispose on all APIs that use the file?

    -Brock
    DevelopMentor
    [url]http://staff.develop.com/ballen[/url]


    > Hi Guys,
    >
    > I'm stuck with a terribly persistant "Access to the path *** is
    > denied" problem. I'm trying to upload a foile using the file control.
    > The code checks if a file of the same name as uploaded exists and if
    > so, attempts to delete the file and then uploads the new file.
    >
    > Dim myFile As File
    >
    > If
    > myFile.Exists(Server.MapPath("..\photos\family\stu dent\" &
    > Session("ChildId") & ".jpg")) Then
    >
    > myFile.Delete(Server.MapPath("..\photos\family\stu dent\"
    > & Session("ChildId") & ".jpg")) ' exception thrown here
    >
    > End If
    >
    > file1.PostedFile.SaveAs(Server.MapPath("..\photos\ family\
    > student\" & Session("ChildId") & ".jpg"))
    >
    > However I keep getting the following error "Access to path ** is
    > denied"
    >
    > I've given ASP.NET all complete access to the folder where the file is
    > to be uploaded. I've even turned on impersonation in the webconfig
    > file and it still doesn't work. It makes no sense. I've tried
    > everything an still no luck. Any code snippets or suggetsions for this
    > problem would be highly appreciated.
    >


    Brock Allen Guest

  4. #3

    Default Re: A very persistant Access To Path Denied Error

    April 8, 2005

    This would be my advise also. Check all the applications that access that
    file and make sure Close is called on all readers and writers! Then I would
    restart the computer (if close was not called, then restarting the computer
    would clear the lock) and try it again. HTH

    Joseph MCAD


    "Brock Allen" <ballen@NOSPAMdevelop.com> wrote in message
    news:370157632482861964794688@msnews.microsoft.com ...
    > Either your application doesn't have write permissions or your application
    > (or someother application) is holding a lock on the file. If you don't
    > have the perms then enable that directory for write access to the user
    > that your ASP.NET app is running as. This is either the local ASPNET
    > account on W2K or the Network Service account on W2K3. If it's not this,
    > then some application has a lock on the file on the filesystem. From the
    > other parts of your application are you making sure to call Close or
    > Dispose on all APIs that use the file?
    >
    > -Brock
    > DevelopMentor
    > [url]http://staff.develop.com/ballen[/url]
    >
    >
    >
    >> Hi Guys,
    >>
    >> I'm stuck with a terribly persistant "Access to the path *** is
    >> denied" problem. I'm trying to upload a foile using the file control.
    >> The code checks if a file of the same name as uploaded exists and if
    >> so, attempts to delete the file and then uploads the new file.
    >>
    >> Dim myFile As File
    >>
    >> If
    >> myFile.Exists(Server.MapPath("..\photos\family\stu dent\" &
    >> Session("ChildId") & ".jpg")) Then
    >>
    >> myFile.Delete(Server.MapPath("..\photos\family\stu dent\"
    >> & Session("ChildId") & ".jpg")) ' exception thrown here
    >>
    >> End If
    >>
    >> file1.PostedFile.SaveAs(Server.MapPath("..\photos\ family\
    >> student\" & Session("ChildId") & ".jpg"))
    >>
    >> However I keep getting the following error "Access to path ** is
    >> denied"
    >>
    >> I've given ASP.NET all complete access to the folder where the file is
    >> to be uploaded. I've even turned on impersonation in the webconfig
    >> file and it still doesn't work. It makes no sense. I've tried
    >> everything an still no luck. Any code snippets or suggetsions for this
    >> problem would be highly appreciated.
    >>
    >
    >
    >

    Joseph MCAD Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139