$dir = opendir($directory); Read an entry from the

$dir = opendir($directory); Read an entry from the directory handle: while (($file = readdir($dir))) { If the read entry is a file, then delete the file if it has not been accessed in the last ten days: if (is_file($directory . “/” . $file)) { $accessTime = fileaTime($directory . “/” .$file); $time = time(); if (($time - $accessTime) > 10*24*60*60) { if (unlink($directory . “/” .$file)) { printf(”File %s is removed from %s directory
n”, $file, $directory); } } If the read entry is a directory, then call the function again with the read entry as its argument. Here, we use the recursive cleanTemporaryFiles() function. Note that we do not call the function again if the read entry is “.” or “..”: } else if (is_dir($directory . “/” .$file) && ($file != “.”) && ($file != “..”)) { cleanTemporaryFiles($directory . “/” . $file); } } Close the directory: closedir($dir); } cleanTemporaryFiles(”c:/temp”); ?> Adding and Deleting Directories int mkdir(string directoryname, int mode) The mkdir()function can be used to create a new directory. The argument directoryname is the path name for the directory to be created. The argument mode specifies the access permissions for a UNIX directory. On Windows this argument is ignored. The mode entry is specified as an octet string and should always start with a zero character. The function returns true on success, falseon failure. The following code creates a new directory C:temptest: Page 247
Note: If you are looking for good and high quality web space to host and run your java application check Vision java hosting services

Comments are closed.