I write this function to delete directory and file but when i 've a directory not 
empty i get error
The code that i write is this:

function DelDir($dir) {

   if (!($handle = opendir($dir)))
      die("Error, it's not possible open $dir");

   while($file = readdir($handle) !== false) {
    if ($file != '.' && $file != '..') {
      if (is_dir("$dir/$file")) {
       DelDir("$dir/$file");
       rmdir("$dir/$file");
      }
      else {
      unlink("$dir/$file");
      }
    }
  }
  closedir($handle);
  if (!(rmdir("$dir"))) {
    die("It's not possible Del <b>$dir</b>");
  }
  else {
  echo("It's okay");
  }
}
DelDir('my_folder');
I receive this warning:
Warning: rmdir(cartella): Directory not empty in c:\programmi\apache 
group\apache\users\test\project\delete.php on line 23
I have set chmod on linux chmod to 777 but i can delete folder only when is empty.
What I do ?
Thanks to all and sorry for my bad language.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to