#1
  1. No Profile Picture
    Steve Schofield
    Guest
    ASP Mastermind (5000+ posts)

    Delete file error: file in use by another process


    <i><b>Originally posted by : Rod McAuley (rodm@rpcorp.com)</b></i><br /><br />In windows 2000 advanced server after a file is uploaded from an asp.net form it cannot be deleted for several minutes. When an attempt is made to delete the file is responds by saying the file is in use by another process. There are no other programs (that I know of) using that file. After 5 or 10 minutes the file may be deleted. Does anyone know what is going on and how I can delete the file immediately after is uploaded.
  2. #2
  3. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2004
    Posts
    6
    Rep Power
    0

    Ever find an answer?


    I am having the same issue. Did you ever get your problem resolved?

    Please let me know,,, if I find anything I will let you know too.

    Thanks,
    Brian
  4. #3
  5. No Profile Picture
    mow
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2004
    Posts
    1
    Rep Power
    0
    I'm having this same problem in ASP.NET; I am creating a file on the server and later would like to modify or delete and cannot access it. So this is not limited to uploaded files.

    I suspect that the ASP runtime is not releasing File resources so they can be garbage collected. Even if you set the handle to the file to Nothing, it still takes a few minutes before you can get delete or write noappend access to the file.

    Is there a call, like in Java, where you tell the system to garbage collect the dereferenced objects? Or other solution?

    Thanks,

    -Martin
  6. #4
  7. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Sep 2004
    Posts
    1
    Rep Power
    0

    Same problem with ASP, but only on one of 2 servers...


    I am having the same problem, and by accident discovered that make making a change to the global.asa file frees up the file and allows it to be overwritten, which stronly suggests that it has something to do with IIS. To make matters worse, I don't have this problem on my development server, only on a staging server, so it's become more difficult to troubleshoot. I've gone over permissions, IIS settings at least a dozen time, and just cannot find a cause... did anyone figure this out?
  8. #5
  9. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2004
    Posts
    6
    Rep Power
    0

    Talking I think I found a fix...


    The fix actually involves using a different code block. Instead of using the file and directory objects, use the fileinfo and directoryinfo objects.

    A sample of the code follows:
    **************
    dim fi as fileinfo

    fi = new fileinfo(PathToFile)

    if fi.exsists then
    fi.delete()
    end if

    **************

    Let me know if this works for you. I have been using it lately and have not ran into this issue.
  10. #6
  11. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2010
    Posts
    2
    Rep Power
    0

    Unhappy Can't Delete File In Use


    That was my first thought to delete the file. It is what we did before with Classic ASP, and it always worked fine. Not sure what the deal is now. The file uploaded just fine. Then the process opened it up to read the file. I was in debugging the process, when it crapped out. Now I cannot access the file again, until after rebooting.

    What is up Microsoft? Why would the file remain in use after an FILE.OPENTEXT? I can't close it now, because it is not open, but your crazy tools and OS says it is. Only option is to come up with a new name and try again. This could be costly on storage space to build processes like this to avoid "File in Use" problems.

    Follow-up: The process was actually able to delete the file after waiting the 15 minutes it took to register here and create this posting.

    Follow-up 1.5 hours later: Spoke too soon. Now I have a file that has been sitting there for over an hour, and it cannot be deleted by the process that created it and essentially owns it. It is the only program that ever used it.
    Last edited by Computer Wizard; January 12th, 2010 at 04:04 PM. Reason: Typo
  12. #7
  13. No Profile Picture
    q97
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Apr 2005
    Location
    Brisvegas
    Posts
    439
    Rep Power
    114
    Without code to look at it is hard to tell what/where the problem could be.

    When you create the file, are you destroying any object that creates/reads the file when it is finished with it ie set objFile = nothing?
  14. #8
  15. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jan 2010
    Posts
    2
    Rep Power
    0

    Cool Access to Microsoft Code


    Nothing? Isn't that old school? Wish I could work the old FileSystrem Object in dot Net. It had EOF. Now you have to look for nothing to find the end of the stream.

    FYI, I am using ASP/VB.Net File Field Control and IO Streams found in the System.IO namespace. Process appears to work OK unless there is a problem like lets say a timeout. By the way, you really should plan for Murphy's Law.

    This is what I am doing.
    See Upload Example in MSDN:Uploading Files Using the File Field Control

    See StreamReader Example in MSDN:How to: Read Text from a File

    Please let me know if something has changed? Will Microsoft let you look at their code in anything other than in a disassembly now so you can arrive at your own solution. I am not interested in working through mountains of undocumented assembler.

    I try to create fool proof stuff. The solution I have arrived at creates a new file using an incremental dataset, if necessary to work error free; and, it cleans up after itself as it goes. The extra work involved is just a real pain in the ***.

    Our old stuff used both ASPUpload and our own routines for Multi-Part binary form Upload with the Classic ASP. This worked for years without a hitch. We were in control of the process. They did not take possession of the file.

    FYI, Microsoft the functions required to create your own upload routines were included with VB6/ASP. They are not supported in .Net, which may be one reason why the ASPUpload and ASPJpeg appear to be stuck on Classic ASP.
  16. #9
  17. No Profile Picture
    q97
    Contributing User
    ASP Discoverer (100 - 499 posts)

    Join Date
    Apr 2005
    Location
    Brisvegas
    Posts
    439
    Rep Power
    114
    Set objFile (or whatever your object is called) = nothing has nothing do with checking the end of a stream and everything to do with releasing an object from memory...
  18. #10
  19. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Feb 2012
    Posts
    1
    Rep Power
    0

    Long Path Tool


    Just try the "Long Path Tool" software. Go to Google and search for "Long Path Tool". This software can easily solve this type of all errors very easily and quickly.
  20. #11
  21. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Hey!


    i solved my own problem similar to you guys , i just dispose the image in the picture box, example:

    picturebox.image.dispose()

    you may be able to delete that. CHEERS! NEW HERE

Similar Threads

  1. msxml - file is being used by another process
    By dirkjanhoek in forum ASP Development
    Replies: 1
    Last Post: February 3rd, 2004, 07:00 AM
  2. delete a file from a folder
    By neoprem in forum ASP Development
    Replies: 5
    Last Post: January 13th, 2004, 01:20 AM
  3. ASP delete file
    By Capricorn in forum ASP Development
    Replies: 1
    Last Post: August 25th, 2003, 10:21 AM
  4. Web serverístatistical analysis
    By cso in forum ASP Development
    Replies: 0
    Last Post: April 19th, 2003, 11:35 AM
  5. I need an example of how to delete a file via asp
    By Steve Schofield in forum ASP Development
    Replies: 1
    Last Post: November 26th, 2001, 04:38 PM

IMN logo majestic logo threadwatch logo seochat tools logo