Results 1 to 5 of 5

Thread: Checking if file is in use by another process

  1. #1

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366

    Checking if file is in use by another process

    I am trying to delete a file that gets moved to another folder.



    If this file gets moved to the new folder, and meets certain criteria, I want to immediately delete the file.



    However, I think the operating system is locking the file during the move, so when I delete it, I get the message...



    The process cannot access the file "C:\myfile.txt" because it is being used by another process.



    Is there any way I can run a loop checking if the file is no longer being used by another process, and then delete it?



    Greg

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

  3. #3

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    Hi Pirate,

    Thanks for the response. However catching the exception was not the problem.

    Anyway, I just made a work around. If the file was in use, I marked it in the database for deletion.

    Then when the app/service runs again it attempts to delete any files marked for deletion.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by greg_quinn
    Hi Pirate,

    Thanks for the response. However catching the exception was not the problem.

    Anyway, I just made a work around. If the file was in use, I marked it in the database for deletion.

    Then when the app/service runs again it attempts to delete any files marked for deletion.
    Poor file . If it knew it's marked for deletion , it would add itself to startup menu ......

    Good workaround btw .

  5. #5

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    Heheh,

    Well the files messed with me in the first place by not being deleted when they wanted to, so I had to take extreme measures !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width