Only criticism is this is using a blocking sync interface... don't do this in a service app that receives requests from externally. You could do largely the same with async, you'd have to replace the array methods with for loops though.
On a very large/deep directory structure (root on a unix system), you'll likely get a stack overflow exception.