tags:

views:

310

answers:

3

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?

+2  A: 

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.

jamessan
+2  A: 

@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.

ghostdog74
+2  A: 

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.

Adam Kennedy