perl's rmtree() failing to delete directory on win32, successful on second try
In Perl, I do a:
rmtree($myfolder);
Often this fails on windows. When ran again, it then succeeds. It seems like somehow it takes a while to delete the files in the folder, and开发者_开发百科 somehow it tries to delete the folder before the files are gone.
Is there a "this one actually works" Perl method to erase an directory with all its contents on Windows?
Do you have a virus scanner running? If it's scanning a file, it has the file open. Windows won't let you delete files/directories that are open by another process.
@OP, whenever things happen, always check whether you can handle those errors. See perldoc File::Path. Under remove_tree(), you can use verbose
and error => \$err
to show you errors encountered.
I took over and greatly improved File::Remove a while back, which is a bit more extreme and paranoid about deleting things.
It might do what you want.
And if it doesn't let me know and I'll improve it.
精彩评论