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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:33:43+00:00 2026-06-09T05:33:43+00:00

My program uses a Telerik ASyncUpload control in order to allow the user to

  • 0

My program uses a Telerik ASyncUpload control in order to allow the user to upload images. The control has been configured to accept only images, and in its FileUploaded event, there’s some extra code doing some additional work (resizing (twice) and converting to JPEG).

However, after the code block below finishes, and my image is saved, the program throws a System.IO exception: “The process cannot access the file because it is being used by another process.”

        protected void RadAsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e) {
        ListViewItem lvwItem = lvwItems.EditItem;
        RadAsyncUpload upl = (RadAsyncUpload)lvwItem.FindControl("RadAsyncUpload1");

        string target = MapPath(upl.TargetFolder);

        try
        {
            foreach (UploadedFile file in upl.UploadedFiles) {

                using (Bitmap originalImage = new Bitmap(file.InputStream)) {

                    System.Drawing.Image cloneImage = (Bitmap)originalImage.Clone();

                    // Resize the picture to max 200 * 200
                    Size mySize = new Size(200, 200);
                    cloneImage = Imaging.resizeImage(originalImage, mySize);

                    // Create a bitmap from the cloned image. Bitmap is needed for saveJpeg routine
                    Bitmap newImage = new Bitmap(cloneImage);

                    // Convert to jpg if necessary
                    if (file.GetExtension() != ".jpeg" || file.GetExtension() != ".jpg") {
                        Imaging.saveJpeg(Path.Combine(target, file.GetNameWithoutExtension() + ".jpg"), newImage, 100);
                    }
                    else {

                    }

                    // Now create a thumbnail
                    Size thumbSize = new Size(50, 50);
                    cloneImage = Imaging.resizeImage(originalImage, thumbSize);
                    Bitmap thumbImage = new Bitmap(cloneImage);
                    Imaging.saveJpeg(Path.Combine(target, file.GetNameWithoutExtension() + "_lille.jpg"), thumbImage, 100);

                    uploadedFileName = file.GetNameWithoutExtension() + ".jpg";
                }
            }
       }
       catch (IOException ex) 
        {

        }
    }

At this point, the two files (200*200 and 50*50) will exist, but upon exiting the routine, I receive the error.

I tried closing and disposing all the images as well as the file.InputStream, but still see the error. I also tried seeing if the UploadedFile could just be discarded, but did not find that method to exist.

I’m fairly certain that there’s a simple solution to it, but I’ve been staring at this for hours, and simply do not see it.

Thanks.

  • 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-09T05:33:45+00:00Added an answer on June 9, 2026 at 5:33 am

    It turns out that my error was caused by the line:

    using (Bitmap originalImage = new Bitmap(file.InputStream))
    

    I replaced that with:

    using (Stream fileStream = file.InputStream) {
       using (System.Drawing.Image originalImage = System.Drawing.Image.FromStream(fileStream)) {
    

    and the error is gone.

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

Sidebar

Related Questions

My C# program uses a web browser control and I programmatically set its html
My program uses MVC. When the user hits New File, I need to check
Assuming that a C# program uses only managed .NET code, is it possible to
My program uses a UISplitViewController as the root view controller. In order to get
The question An open source program uses CVS for version control. I would like
My Java program uses ProcessBuilder (with redirectErrorStream set true) and has a loop that
My WPF program uses a third party map package which has a WPF map
My program uses wx.ProgressDialog to give feedback on a process that is in multiple
My program uses some external programs that i included in the Files folder. In
My program uses sqlite3 plus python. It works fine with python 2.6.2 I moved

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.