the process cannot access the file because it is being used by another process

Discussion in 'ASP .Net' started by bala, Apr 7, 2005.

  1. bala

    bala Guest

    Hi All,
    Sorry for repost

    I have a popup for image upload with a upload button,save button and one
    close button
    I am uploading images with a file control after browsing when I click on
    upload button it
    upload the file to some folder /xyz/temp/ folder with name 101.jpg
    now i close the popup.
    now when i again open and try to upload (upload the file to same folder
    /xyz/temp/ folder with name 101.jpg)
    it gives me exception on this line
    inputFile.SaveAs(MapPath(/tmp+"//"+fileName));
    saying
    "the process cannot access the file (101.jpg)because it is being used by
    another process"
    this exception is thrown.
    now if i restart the asp.net worker process this exception doesnt comes
    that mean the file is cached in memory by the asp.net worker process.

    Thanks in advance
    bala
    bala, Apr 7, 2005
    #1
    1. Advertising

  2. Patrick Olurotimi Ige, Apr 7, 2005
    #2
    1. Advertising

  3. bala

    bala Guest

    Hi

    Thank for the reply

    I am not geeting what to release the file

    I m creating a object of HttpPostedFile

    After use I am setting it to null

    There is no property like dispose with it

    I m sending u the code fragment

    On postback

    if(IsPostBack)

    {HttpPostedFile uploadedFile = file.PostedFile;

    try

    {if(uploadedFile.ContentType=="image/pjpeg")

    {uploadedFile.saveas(path+"101.jpg");

    uploadedFile=null;

    }}

    Catch(){}

    When user clicks on preview I am creating a datatable contains the

    ImageUrl and Image(typeof(byte[])

    Now I am displaying the image in pdf formate in another frame

    I am not geeting what to release the file

    thanks

    bala
    bala, Apr 7, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page