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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:47:09+00:00 2026-06-13T15:47:09+00:00

I have one image displayed in picture box control in my application. Now I

  • 0

I have one image displayed in picture box control in my application. Now I want to update that Image when my application is running and image already has been used by the application.

I used this line of code to update my logo image:UPDATED CODE

  public void showRow()
  {
      string _fileName = Application.StartupPath + "\\Logo" + ".png";

      using (var stream = new FileStream(_fileName, FileMode.Open, FileAccess.Read))
      {
          var img = Image.FromStream(stream);
          pbStoreLogo.Image = img;
      }
  }

  private void btnsave_Click(object sender, EventArgs e)
  {
      using (var m = new MemoryStream())
      {
          pbStoreLogo.Image.Save(m,System.Drawing.Imaging.ImageFormat.Png);
          var img = Image.FromStream(m);
          img.Save(Application.StartupPath + "\\Logo" + ".png");
      }
  }

And it through exception: A generic error occurred in GDI+.

So please suggest me how to change my image at run time or provide me solution of this exception.

  • 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-13T15:47:10+00:00Added an answer on June 13, 2026 at 3:47 pm

    To save an Image object from your application to a physical path in file system, you have to ensure the file is not being used by your application or any other application. Hence you have to take care not only how you are saving the file, but also how you’re reading the image to picturebox.

    To free up the physical resource, you have to read the file to a stream and then form the image from the stream and then assign the image to picture box. Like this:

    string _fileName = Application.StartupPath + "\\Logo" + ".png";
    
    using (var stream = new FileStream(_fileName, FileMode.Open, FileAccess.Read))
    {
        var img = Image.FromStream(stream);
        pbStoreLogo.Image = img;
    }
    

    And while saving:

    using (var m = new MemoryStream())
    {
        pbStoreLogo.Image.Save(m, ImageFormat.Png);
        var img = Image.FromStream(m);
        img.Save(_fileName);
    }
    

    If you are having the file as a resource file in your project, then all these hassles shouldn’t be there. You can just do:

    pbStoreLogo.Image = Properties.Resources.Image1;
    

    and

    pbStoreLogo.Image.Save(_fileName);
    

    You can find more info in this SO question.

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

Sidebar

Related Questions

I have one image animation started using GameQuery. Now I want to stop the
i have created one image but problem is that when i save image from
I have one big buffer image. I want to create another buffer image with
I have a program that reads one image file, makes some changes on that
There is one image on LinearLayout. I have to move that image in any
Hi iam new to C# and have loaded the image in the picture box
I have an application that will get a list of image filenames and put
I have a ImageView which shows a picture that has been taken from the
I have a picture box which reads in an image from a folder to
I have one image submit button like this <input id=enter name=enter type=image value=Login src=images/btn_login.jpg/>

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.