Hi,
Can somebody help me with this:
Here is what i want 2 do:
before deleting a dir check if the dir is
empty! If not then return a error message!
Is this the way or is there a better one?
/ BEGIN code /
$dirhandle='a_path';
//read '.' and '..' first
readdir($dirhandle);
readdir($dirhandle);
if ((readdir($handle)== false)
{
$feedback='Dir not empty';
}
else
{
rmdir($dirhandle);
$feedback='Dir removed!';
}
/ END code /
At first i want to something like this:
if (rmdir($dirhandle)==0)
{
$feedback='Dir not empty';
}
But ofcourse when exucuting the command rmdir there is generated an error when dir is not empty!
I understood in my other post
(http://www.phpbuilder.com/forum/read.php3?num=2&id=179561&thread=179554) .
That i should place a @ before "rmdir($dirhandle)" but when i do that my if statement doesn't work anymore because it doesn't gives a result back!
Anyone of you has an idea???
Thx