Reputation: 175
I am trying to erase a entire directory with all it content with rmtree
but I am getting the following exception:
[WinError 32] The process cannot access the file because it is being used by another process
the folder that I am trying to erase have some word docs that were opened with win32com.client above in the code, my code to erase is:
shutil.rmtree('destinationFolder')
I also tried to erase every file at once iterating throw the files of the folder and then os.remove
but it doesn't work either, throwing the same error.
Upvotes: 0
Views: 479
Reputation: 1878
the folder that i am trying to erase have some word docs that were oppened with win32com.client above in the code
That's exactly why Python throws that error. Try closing these docs before deleting the folder.
Upvotes: 5