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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:42:54+00:00 2026-05-12T20:42:54+00:00

Good day all, I am having some trouble with image permissions. I am loading

  • 0

Good day all,

I am having some trouble with image permissions.

I am loading an image from file, resizing it and then saving it out to another folder.
I am then displaying this like so:

    uriSource = new Uri(Combine(imagesDirectoryTemp, generatedFileName), UriKind.Absolute);

    imgAsset.Source = new BitmapImage(uriSource);

This is working fine, the trouble comes if the user then selects another image immediately after and tries to save it over the original file.

An exception is generated upon saving my image "ExternalException: A generic error occurred in GDI+."

After some playing around i have narrowed the error down to imgAsset.Source = new BitmapImage(uriSource); as removing this line and not setting the imagesource will allow me to overwrite this file many times.

I have also tried setting the source to something else, before re-saving in the hope that the old reference would be disposed, this was not the case.

How can i get past this error?

Thanks,
Kohan

Edit

Now using this code i am not getting the exception however the image source is not updating. Also since i am not using a SourceStream, im not sure what i need to dispose of to get this working.

       uriSource = new Uri(Combine(imagesDirectoryTemp, generatedFileName), UriKind.Absolute);

       imgTemp = new BitmapImage();
       imgTemp.BeginInit();
       imgTemp.CacheOption = BitmapCacheOption.OnLoad;
       imgTemp.UriSource = uriSource;
       imgTemp.EndInit();

       imgAsset.Source = imgTemp;
  • 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-12T20:42:55+00:00Added an answer on May 12, 2026 at 8:42 pm

    You’re almost there.

    • Using BitmapCacheOption.OnLoad was the best solution to keep your file from being locked.

    • To cause it to reread the file every time you also need to add BitmapCreateOptions.IgnoreImageCache.

    Adding one line to your code should do it:

      imgTemp.CreateOption = BitmapCreateOptions.IgnoreImageCache;
    

    thus resulting in this code:

      uriSource = new Uri(Combine(imagesDirectoryTemp, generatedFileName), UriKind.Absolute);
      imgTemp = new BitmapImage();
      imgTemp.BeginInit();
      imgTemp.CacheOption = BitmapCacheOption.OnLoad;
      imgTemp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
      imgTemp.UriSource = uriSource;
      imgTemp.EndInit();
      imgAsset.Source = imgTemp;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day, I'm having a problem with asp.net 2.0 viewstate. Basically, I want to
Good day all I wrote the following method: private void RegisterEvent(object targetObject, string eventName,
Good day all, First of all, maybe i went about this the wrong way
Good day! I've recently switched from IIS 6.0 to IIS 7.x and I'm in
Good day... I have huge trouble with this and it drives me insane. My
hope you're having a good day. I have been programming a IRC chatbot in
Good day all, for running multiple threads concurrently is it advisable to create different
Good day to all. I have the following setup: A page with html, js,
Good day, We just converted our web application .NET 1.1 to .NET 2.0. We
Good day, In visual studio 2005, when I drop a webcontrol in the designer,

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.