Cant write to a file

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

  1. #1

    Default Cant write to a file

    Hi

    The following code is what I use to open the file
    Dim sw As StreamWriter =
    File.AppendText("C:\Inetpub\wwwroot\IView\log\errW ebLog.txt")

    These are the following permissons I have set:

    The ASPNET account set to anonymous login.
    The ASPNET account has read/write permissions on the folder
    THe folder's properties in IIS has read/write set .

    I get the following error message when i try and open and write to a
    file in a directory under IIS :

    System.UnauthorizedAccessException: Access to the path
    "C:\Inetpub\wwwroot\IView\log\errWebLog.txt" is denied. at
    System.IO.__Error.WinIOError(Int32 errorCode, String str) at
    System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
    access, FileShare share, Int32 bufferSize, Boolean useAsync, String
    msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String
    path, FileMode mode, FileAccess access, FileShare share, Int32
    bufferSize) at System.IO.StreamWriter.CreateFile(String path, Boolean
    append) at System.IO.StreamWriter..ctor(String path, Boolean append,
    Encoding encoding, Int32 bufferSize) at
    System.IO.StreamWriter..ctor(String path, Boolean append) at
    System.IO.File.AppendText(String path) at
    IView.quotethanks.WriteError(String errStr) in
    C:\Inetpub\wwwroot\IView\quotethanks.aspx.vb:line 176

    Any help will be appreciated

    Thanks
    Damian Guest

  2. Similar Questions and Discussions

    1. Can't write to a file using File class
      hi every body I wanna write into a file for logging purpose, but I always got an error when I write to the file ... the code is:...
    2. write value from flash file to an external file
      how can I write value from flash file to an external file like (text file or xml file)
    3. advice needed... cf write data to xml file for use in flash app thatuses xml file
      I'm wondering if it is possible to use CF to: 1) connect to existing db; 2) get specific data from table; 3) write it to an xml file that would...
    4. Why i cannot write a file, even i add a permission to that file.
      My web site user should change some files in the root folder. Why the following code is not working. I dont want to manually give permission for...
    5. log file sync vs. log file parallel write ?
      On 11 Dec 2002 14:48:41 -0800, bchorng@yahoo.com (Bass Chorng) wrote: The writes requested by a log file sync are evidently processed by...
  3. #2

    Default RE: Cant write to a file

    Hi Damian,

    If you are running Windows 2003, you need to give IIS_WPG Group rights on
    that folder. That is the account under which the application runs in Windows
    2003 IIS 6.0

    Write back if it doesnt help.

    Thanks.

    "Damian" wrote:
    > Hi
    >
    > The following code is what I use to open the file
    > Dim sw As StreamWriter =
    > File.AppendText("C:\Inetpub\wwwroot\IView\log\errW ebLog.txt")
    >
    > These are the following permissons I have set:
    >
    > The ASPNET account set to anonymous login.
    > The ASPNET account has read/write permissions on the folder
    > THe folder's properties in IIS has read/write set .
    >
    > I get the following error message when i try and open and write to a
    > file in a directory under IIS :
    >
    > System.UnauthorizedAccessException: Access to the path
    > "C:\Inetpub\wwwroot\IView\log\errWebLog.txt" is denied. at
    > System.IO.__Error.WinIOError(Int32 errorCode, String str) at
    > System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
    > access, FileShare share, Int32 bufferSize, Boolean useAsync, String
    > msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String
    > path, FileMode mode, FileAccess access, FileShare share, Int32
    > bufferSize) at System.IO.StreamWriter.CreateFile(String path, Boolean
    > append) at System.IO.StreamWriter..ctor(String path, Boolean append,
    > Encoding encoding, Int32 bufferSize) at
    > System.IO.StreamWriter..ctor(String path, Boolean append) at
    > System.IO.File.AppendText(String path) at
    > IView.quotethanks.WriteError(String errStr) in
    > C:\Inetpub\wwwroot\IView\quotethanks.aspx.vb:line 176
    >
    > Any help will be appreciated
    >
    > Thanks
    >
    ranganh Guest

  4. #3

    Default RE: Cant write to a file


    Hi rangah,

    I am running Windows XP and IIS 5.1 ( this is my developemnt machine ).
    For the live server it will be Windows 2000, IIS 5.0


    Thanks


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Damian M 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