Unauthorized Access problem writing file

Posted on 2006-05-19
Last Modified: 2008-03-04
I am getting an unauthorized access exception when i try to write to file in the temp directory.  I think that i have added the appropriate premissions through iis but i guess not.

 anonomyous access is checked and integrated windows authentication is checked

i have also added impersonation = true  to the web.config.

here is the code it is bombing on

Public Function getImageFile() As String
            Dim s As Stream
            Dim i As Image
            Dim b() As Byte
                Kill(StartupPath & "\temp\gemini.tx")
            Catch ex As Exception

            End Try
       ------->>>    Dim fs As FileStream = IO.File.OpenWrite(StartupPath & "\temp\gemini.tx")
            b = z_dTable.Rows(z_index)("cutedoc_image")
            fs.Write(b, 0, b.Length)
            Return fs.Name
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

Any ideas?
Question by:jon1b
    LVL 27

    Assisted Solution

    in IIS did you have Read/Write permission for the file and the containing folder?
    LVL 19

    Accepted Solution

    ASPNet user must ave write and delete permission on startup folder and sub folders
    And also.. The windows account which is running the ASP.NET application pool ( normally localservice account)

    Melih SARICA

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now