0

If we want to move or delete a folder, but some of its contained files are currently being used, the operation will likely fail after it has already started, and the folder could be left in a half-way, "corrupt" state.

Is there a fast way to detect in advance that this will happen to avoid starting the operation?

Caveat: I realize that if we perform the check beforehand, it might pass, but a file might start being used during the operation. Maybe in that case the solution would be to restore the folder's contents as they were before the operation started.

LoneCodeRanger
  • 413
  • 6
  • 18
  • if operations on folder is made by another program, maybe just do a try delete in a loop? – Je Je Apr 07 '23 at 09:51

1 Answers1

0

If it is a folder then there are multiple ways to do it like some example

  1. You can check if a folder has a handle on it using the next function - Reference
  2. Try renaming under exception - Reference
  3. Sometimes permission errors may leads to terminate the opertion if folder is being opened or used by other process in such cases os module does have the os.access function to check access