Unauthorized Access problem writing file

Posted on 2006-05-19
Medium Priority
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

by:Sammy Ageil
Sammy Ageil earned 1000 total points
ID: 16721509
in IIS did you have Read/Write permission for the file and the containing folder?
LVL 19

Accepted Solution

Melih SARICA earned 1000 total points
ID: 16721597
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)


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

830 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