I have a code to go inside the subfloder to delete files before deleting the folder. For some strange reason, the code is not recursing.
The code goes to 'if' statement after hitting deleteFiles(temp, days); instead of starting from first line of deleteFiles().
btw, does anyone has the code to delete folder & it's subfolders (after deleting the files in them)?
posted 8 years ago
[PI]: The code goes to 'if' statement after hitting deleteFiles(temp, days); instead of starting from first line of deleteFiles().
But the first line of deleteFiles() is an if statement - if we ignore the comment, anyway. Which of the many if statements are you talking about? I suspect you need to add some more logging statements, just for debugging, to find out exactly what is happening here. Or run it through a debugger. How do you know it's not recursing? Are you sure that the files you're trying to delete are old enough? Try running with days = 0 to be sure.
I don't see a problem with the code offhand. But one thing that looks rather strange is passing days as a String, and parsing it again and again every time you find a new file. I would convert it to a timestamp right away:
That's a minor point. Not a bug, but re-parsing it just seems so inefficient.