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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:11:19+00:00 2026-05-16T01:11:19+00:00

In asp.net, we have uploaded a .jpeg file and saved this as bitmap image

  • 0

In asp.net, we have uploaded a .jpeg file and saved this as bitmap image using following code

HttpPostedFile uploadFile;
System.IO.Stream stream = uploadFile.InputStream;

 using (System.Drawing.Image imgSource = System.Drawing.Bitmap.FromStream(stream))
{
    System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);

    using (System.Drawing.Image imgThumbnail = imgSource.GetThumbnailImage(imgSource.Width, imgSource.Height, myCallback, IntPtr.Zero))
    {

       imgThumbnail.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);

        imgThumbnail.Dispose();
    }
    imgSource.Dispose();
}

stream.Close();
stream.Flush();
stream.Dispose();

After upload, if we perfrom delete operation it throws error.

We are following code to do so;

if (File.Exists(filePath))
{
     File.Delete(filePath);

}

The exception says:The process cannot access the file ‘abc.jpg’ because it is being used by another process.

Does anyone know, why this is happening ?
Thanks in advance.

  • 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-16T01:11:20+00:00Added an answer on May 16, 2026 at 1:11 am

    The garbage collector doesn’t release it’s resources to your file immediately.

    You can try and run GC.Collect() to “force” the garbage collector to do it’s thing. Do this after you have Disposed your file and before you try and delete it.

    Edit: I you have some anti virus software on your machine it’s likely that it is what is using your file. Same if you have an Explorer window open to the folder where the image is created etc.

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

Sidebar

Related Questions

sending mail along with embedded image using asp.net I have already used following but
I'm trying to rescale uploaded jpeg in asp.net So I go: Image original =
I have an image upload facility in my asp.net project, when uploaded a thumbnail
I have my asp .net website. I have uploaded that. But is shows code
I uploaded asp.net code to C:\inetpub\wwwroot\myfolder on IIS using FTP. It won't run properly
I have a working copy of asp.net mvc site locally. I just uploaded the
how can i use request.querystring in asp.net.i have a linkbutton and this is in
I'm quite new to asp.net MVC. I'm following the NerdDinner tutorial and have created
I have an ASP.NET MVC application for which I store uploaded content files in
I have uploaded a site built with asp.net 2.0 in a sub directory created

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.