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 7510073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:07:17+00:00 2026-05-29T23:07:17+00:00

The odd thing is that something like System.IO.File.Delete() works and the file gets deleted

  • 0

The odd thing is that something like System.IO.File.Delete() works
and the file gets deleted but will give “access to path is denied error” for .Move() operation.
All files are located in the same folder, user “Network service” has all
full control rights for the folder and all subfolders in it etc.

Folders are located in the project directory and can be seen in solution explorer.

Exception Details: System.UnauthorizedAccessException: Access to the path is denied.

      foreach(var info in FileActions.Where(x => x.OldSortOrder != x.SortOrder))
    {
        string FileToRename;
        string NewName;
        string OldFilePath;
        string OldFileThumbPath;


            FileToRename = info.ProductID + "/" + info.OldSortOrder + "-" + info.ImageID + ".jpg";
            NewName = info.SortOrder + "-" + info.ImageID + ".jpg";
            OldFilePath = System.Web.HttpContext.Current.Request.MapPath("~/Content/ProductImages/"  + FileToRename);
            OldFileThumbPath = System.Web.HttpContext.Current.Request.MapPath("~/Content/ProductImages/" + info.ProductID + "/thumbs/" + FileToRename);

            System.IO.File.Move(OldFilePath, NewName);
            System.IO.File.Move(OldFileThumbPath, NewName);



    }
  • 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-05-29T23:07:18+00:00Added an answer on May 29, 2026 at 11:07 pm

    Its because you map the path for the first files but not for the NewName.

    So did not have the full path to know what to rename/move the file, and needs the full path to work correctly.

    With out the path this is probably try to move it on the default folder of the asp.net pool that is probably don’t have this permissions.

    So the code will be

    NewName = System.Web.HttpContext.Current.Request.MapPath("~/Content/ProductImages/"  
         + info.SortOrder + "-" + info.ImageID + ".jpg" );
    

    and debug this lines to see if the directories and files are all correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that question sounds a little odd but i will try to explain
I'm writing something that I would like to print in Latex and I'm using
This may seem like an odd question, but I have my own reasons for
I have something that looks like this H1 H2 CHK1 N1 D1 CHK2 N2
This is probably a truly basic thing that I'm simply having an odd time
It's one of those things that seems to have an odd curve where the
This is an odd thing I've just run into. I have a web application
Can someone explain to me this odd thing: When in python shell I type
I noticed an odd (to me) mod_rewrite thing happening. Fixing it is not important
An odd issue that I have been trying to address in a project -

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.