Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8978457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:37:04+00:00 2026-06-15T19:37:04+00:00

Hi I seem to be having a problem when uploading images in asp.net.When I

  • 0

Hi I seem to be having a problem when uploading images in asp.net.When I tryed to upload an Image I get this error:

Access to the path ‘D:\Projects IDE\Visual Studio\MyWork\Websites\Forum\Images\avatar\userAvatars\aleczandru’ is denied.

I have set application pools Identoty to NETWORKSERVICE ando also added the NETWORK SERVICE account to the Images folder with full permision but I still get the same error.

This is my code:

private void addImageToApp()
{
    string path = "~/Images/avatar/userAvatars/" + User.Identity.Name;

    createPath(path);
    if( Directory.Exists(HostingEnvironment.MapPath(path)))
    {
        //try {
              UploadImage.SaveAs(HostingEnvironment.MapPath(path));
          //    MultiViewIndex.ActiveViewIndex = 0;
        //}catch(Exception ex)
        //{
          //     AvatarDetails.Text = ex.Message;
        //}  
    }
}

private void createPath(string path)
{  
    string activeDir = HostingEnvironment.MapPath("~/Images/avatar/userAvatars");
    if( !Directory.Exists(Server.MapPath(path)) )
    {
        string newPath = Path.Combine(activeDir, User.Identity.Name);
        Directory.CreateDirectory(newPath);
    }
}

What else can I do to solve this problem?

EDIT

Hi at this point I have full permision control to the following USERS:

  • Authetificated Users
  • IUSR
  • SYSTEM
  • NETWORK SERVICE
  • IIS_WPG
  • Administrator
  • USers

Is it posible that I need to set any configuration to IIS in order for this to work?

EDIT

I have messed around with SQL-SERVER for the last couple of days in order to make this work so I might have missconfigured something form what I understand NETWORK SERVICE is stored in SQL-SERVER master.db database.I seem to be having two network service logins may this be the problem?I remember when I first checked it I had none now I have two:

enter image description here

EDIT

This is the print with the permisions I added to the folder:

enter image description here

EDIT : Complete error

enter image description here

StackTrace:

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:37:06+00:00Added an answer on June 15, 2026 at 7:37 pm

    In method CreatePath you are creating folder ‘D:\Projects IDE\Visual Studio\MyWork\Websites\Forum\Images\avatar\userAvatars\aleczandru’.

    Then, you try to save the uploaded image with the filename ‘D:\Projects IDE\Visual Studio\MyWork\Websites\Forum\Images\avatar\userAvatars\aleczandru’.

    You can’t have a folder and a file with the same name. If you try to do this, the OS will tell you access is denied.

    What happens if you try this in a command prompt

    I suppose you want to either create a filename inside folder aleczandru, or you meant to save the file as aleczandru.png or something in folder userAvatars.

    Assuming your UploadImage is a FileUpload control, you can save the file to the user’s folder using the original file name of the uploaded file.

    UploadImage.SaveAs(HostingEnvironment.MapPath(
        Path.Combine(path, UploadImage.FileName)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i having problem in converting this C# code into VB.net. The loadLecturer seem to
I seem to be having a problem removing the image in UIScrollView. I was
I'm having a problem with my site http://artygirl.co.uk/pixie/about/ I can't seem to get the
I'm really having a problem finding out how to fix this. I cannot seem
I seem to be having a problem with this jquery code. I want to
I'm having problem with getting ServiceStack [Authentication] attribute to work in ASP.Net MVC4 controller,
I'm having this problem with a .NET DropDownList control. PROBLEM : Every time I
I seem to be having a problem checking if a string exists in my
I seem to be having a problem with checking for list equality. In my
I seem to be having a problem with my footer growing to 100% width

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.