The process cannot access the file 'xxx' because it is being used by another process.

Last post 10-02-2008, 9:56 AM by msalti. 4 replies.
Sort Posts: Previous Next
  •  10-01-2008, 9:34 AM 44472

    The process cannot access the file 'xxx' because it is being used by another process.

    I have an Uploader control on my page, doing a simple openStream() on the FileUploaded event (not using ajax, just straight up postback) and I keep on getting this error:
     
    The process cannot access the file 'xxx' because it is being used by another process.
     
    Any ideas?
     
    Thanks!
     
    Stack Trace...
     

    [IOException: The process cannot access the file 'xxxxxxx' because it is being used by another process.]
     
    System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7712640
     
    System.IO.File.Delete(String path) +7572872
     
    CuteWebUI.i.Delete(Guid guid) +44
     
    CuteWebUI.UploaderBase.System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent() +432
     
    System.Web.UI.Page.RaiseChangedEvents() +165
     
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1485

    Regards,

    Moe
  •  10-01-2008, 12:51 PM 44480 in reply to 44472

    Re: The process cannot access the file 'xxx' because it is being used by another process.

  •  10-01-2008, 2:13 PM 44491 in reply to 44480

    Re: The process cannot access the file 'xxx' because it is being used by another process.

    Hi Adam,
     
    It is interesting, in that last post I was reading into a byte[].
     
    I was doing the following which still caused that same error...
     
     
    using (Stream stream = args.OpenStream())
    {
       Document doc = new Document(stream);
       tbRadContent.Html += ConvertWordDocToHtml(doc);
    }
     
    Am I to understand that the stream from the uploader object shouldn't be used directly?
     
    Thanks!

    Regards,

    Moe
  •  10-01-2008, 8:22 PM 44495 in reply to 44491

    Re: The process cannot access the file 'xxx' because it is being used by another process.

    Hi msalti,
     
    That is strange. Could you try it again for this code ?
     
    using (Stream stream = args.OpenStream())
    {
     
    }
     
    -----
     
    Ajax Uploader is trying to delete the temporary file when the uploaded event is finished.
     
    It should be OK when the stream is disposed.
     
    If the error still exists , you can call
     
    args.Persist();
     
    then that temporary file would be deleted after 1 hour.
     
     
    Regards , Terry .
     
     
     
  •  10-02-2008, 9:56 AM 44525 in reply to 44495

    Re: The process cannot access the file 'xxx' because it is being used by another process.

    Hi Terry,
     
    I  tried what you asked, and it worked just fine.
     
    I ended up fixing the problem by reading the bytes in to an array and creating a new memory stream to create my Aspose document. 
     
    I figure that maybe aspose is doing something to the stream thus causing this error to happen.
     
    Anyways all good for now.
     
    Thanks for all the help.

    Regards,

    Moe
View as RSS news feed in XML