"isFolderEmpty" function
Does anyone know what is the best way to check if some directory is empty or not.
This fn need to be very "light" for efficient use within a for-loop. I already have a solution but I'm curious if there better solution.
This fn need to have only one argument which represent directory path.
Something like this
fn isFolderEmpty folder:/*path String*/ = ( )
Comments
I got some errors.
I'm currently working on 3ds Max 2012.
Rodman
...
I corrected code below. I put only one real directory "c:\temp".
U need to change directory list and filename and then make a test
bga
.
It works now. You made a simple mistake with the boolean value.
I prefer to put all inside the parenthesis of the function, it makes thing clearer to verify.
Rodman
...
I purposely made this mistake to see if you are ready for first assignment. :)
Ok. You passed the test :)
Wait for my mail.
bga
:)
Rodman
...
You are close.Nice try.
What if you have inside "c:\\test" directory only one folder (not files) and that folder have another folder and so on where last folder only contains files.
Also if you put this fn inside for-loop you will create dotnet class over and over again. That's not so eficient. Try again
;)
bga
;)
Rodman
...
Ok that is even more close but still just think about this:
What if you have something like this
You will then also create two .net classes over and over again
bga
.
I'm not familiar with memory efficiency. I'll tell you later if I have a better function, but for now, that's all I can give.
Let's pray for the divine answer. :D
Rodman
...
You deserve to see the answer :)
You can extend this struct but for now you can also check if specific file is inside folder using different pattern. Also U need to check if directory exists.
bga