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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:58:45+00:00 2026-05-12T11:58:45+00:00

in my page. when i upload image i did image management. after that i

  • 0

in my page. when i upload image i did image management. after that i want to delete the original image but i am getting error that the file is already using, like below
(The process cannot access the file ‘D:\sasiweb\myimage\Images\jalsa.jpeg’ because it is being used by another process.)

and this is my code

protected void sizeManage(string filename)
{

    string fn = Server.MapPath("~/Images/" + filename );

    System.Drawing.Bitmap newimg = new System.Drawing.Bitmap(fn);
    int h = newimg.Height;
    int w = newimg.Width;

    if (w > 100)
    {
        objJpeg = new ASPJPEGLib.ASPJpeg();
        objJpeg.Open(Server.MapPath("~/Images/" + FileUpload1.FileName.ToString()));

        int L = 100;
        objJpeg.Width = L;

        objJpeg.Height = objJpeg.OriginalHeight * L / objJpeg.OriginalWidth;
        objJpeg.Save(Server.MapPath("~/Images/" + "small" + FileUpload1.FileName));

        string path = Server.MapPath("~/Images/" + FileUpload1.FileName.ToString());
        FileInfo file = new FileInfo(path);
        file.Delete();


    }
    else
    {

    }


}


protected void Button1_Click(object sender, EventArgs e)
{

    FileUpload1.SaveAs(Server.MapPath("~/Images/" + FileUpload1.FileName.ToString()));
    sizeManage(FileUpload1.FileName.ToString());

}

i am getting error at file.delete();

(The process cannot access the file ‘D:\sasiweb\myimage\Images\jalsa.jpeg’ because it is being used by another process.)

  • 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-12T11:58:45+00:00Added an answer on May 12, 2026 at 11:58 am

    You have to close

    objJpeg
    

    to do this operation.

    Since the file is opened using objJpeg object it has to be freed to delete the file.

    string path = Server.MapPath("~/Images/" + FileUpload1.FileName.ToString());
    FileInfo file = new FileInfo(path);
    
    objJpeg.Close(); // release the resources held by the object
    file.Delete();
    

    or you can code file open process in the using statement.

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

Sidebar

Related Questions

I want to partially update page when i upload or delete the image. What
i am trying to upload an image from a jsp page using servlet. but
I'm making a page where the user upload a file. I want an if
I've got an image upload page that works just fine when I only upload
I am designing an image file upload page for a website and, on Submit,
I want to upload image with the help of ajax or jQuery without page
How to upload image that is nested in img-element of the page (i.e. image
I have an image upload page (single page). When submitted it check filesize and
hai guys, I want to upload images through my web page to a folder
I am implementing a jquery file upload page. While a user is adding files,

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.