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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:21:40+00:00 2026-06-02T22:21:40+00:00

I have a little problem when i try to upload my data and a

  • 0

I have a little problem when i try to upload my data and a image.

the problem is:

System.IO.IOException: The process cannot access the file 'C:\MyWebSites\Class\OriginalImages\IMG_9209.JPG' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at Admin_InsertStudent.Button1_Click(Object sender, EventArgs e)

C#:

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using System.Text;

public partial class Admin_InsertStudent : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
        if (FileUpload1.HasFile)
        {
            string tempPath = "OriginalImages";
            string imgPath = "StudentImages";
            string savePath = Path.Combine(Request.PhysicalApplicationPath, tempPath);
            string TempImagePath = Path.Combine(savePath, FileUpload1.FileName);

            string imgSavePath = Path.Combine(Request.PhysicalApplicationPath, imgPath);
            string StudentImageNormal = Path.Combine(imgSavePath, FileUpload1.FileName);
            string StudentImageThumbnail = Path.Combine(imgSavePath, "t__" + FileUpload1.FileName);
            string extension = Path.GetExtension(FileUpload1.FileName);

            switch (extension.ToLower())
            {
                case ".png":
                    goto case "Upload";
                case ".gif":
                    goto case "Upload";
                case ".jpg":
                    goto case "Upload";
                case "jpeg":
                    goto case "Upload";

                case "Upload":
                    FileUpload1.SaveAs(TempImagePath);

                    ImageTools.GenerateTumbnail(TempImagePath,StudentImageNormal, 400, 300, true, "High");

                    ImageTools.GenerateTumbnail(TempImagePath, StudentImageThumbnail, 120, 90, true, "medium");

                    lblMessage.Text = "Billedet" + FileUpload1 + "er nu uploadet";

                    string FirstName = Convert.ToString(txtFirstName.Text);
                    string MiddleName = Convert.ToString(txtMiddelName.Text);
                    string LastName = Convert.ToString(txtLastName.Text);
                    string BirthDay = Convert.ToString(txtBirthDay.Text);
                    string City = Convert.ToString(txtCity.Text);
                    string Pic = "OriginalImages/StudentImages/" + FileUpload1.FileName;
                    string WebSite = Convert.ToString(txtWebSite.Text);

                    break;

                default:
                    lblMessage.Text = "Denne Filetype er ikke tilladt";
                    return;
            }

        }
    }
    catch (Exception err)
    {
        lblMessage.Text = err.ToString();
    }
        } }

Hope someone can help me 🙂

  • 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-02T22:21:42+00:00Added an answer on June 2, 2026 at 10:21 pm

    After uploading a file you have to release it.

    yourFile.Dispose();
    

    MSDN

    Use this method to close or release unmanaged resources such as files,
    streams, and handles held by an instance of the class that implements
    this interface. This method is, by convention, used for all tasks
    associated with freeing resources held by an object, or preparing an
    object for reuse.

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

Sidebar

Related Questions

i have little problem with boost::asio library. My app receive and process data asynchronously,
i have a little problem when i try to attach a class to an
I have a little Problem in Blitzmax. I try to read an INI-file and
I have this little problem, that I cannot figure out which arguments to pass
I have a little problem with a query. I'm selecting data using the between
I have a little problem with encoding. The data in db is ok, when
I have a little problem with following VHDL code: process (zbroji) begin if rising_edge(zbroji)
I have a little problem. I try to replace a string(well a line) by
I have a little problem. I try to add an element in XML with
I have a little problem with my script. When I try to run it

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.