I have asked this question and I couldn't figure out the solution. I've used different approach, shutil, pathlib but none of them work. Can someone help me resolve the issue I am having please? Thank you very much in advance for helping.
Error Message:
Traceback (most recent call last): File "C:\Test.py",
line 304, in <module>dir_path.rmdir() # remove
directory File "C:\Program Files\Python310
\lib\pathlib.py", line 1213, in rmdir
self._accessor.rmdir(self)
PermissionError: [WinError 32] The process cannot access
the file because it is being used by another process:
'C:\\Test\\Folder2'
The Code:
from pathlib import Path
dir_path = Path.home() / 'C:/Test/Folder1/'
dir_path.rmdir() # remove directory
dir_path = Path.home() / 'C:/Test/Folder2/'
dir_path.rmdir() # remove directory