Hello in a recent plugin that I am developing I have come across an error in the console: PHP: Warning: unlink(C:\Users\test\Desktop\new\/worlds/TnTg1\region\r.-1.-1.mca): Permission denied in C:\Users\test\Desktop\new\plugins\pvp\src\pvp\Main.php on line 301Warning: unlink(C:\Users\test\Desktop\new\/worlds/TnTg1\region\r.-1.0.mca): Permission denied in C:\Users\test\Desktop\new\plugins\new\src\new\Main.php on line 301Warning: unlink(C:\Users\test\Desktop\new\/worlds/TnTg1\region\r.0.-1.mca): Permission denied in C:\Users\test\Desktop\new\plugins\pvp\src\pvp\Main.php on line 301Warning: unlink(C:\Users\test\Desktop\new\/worlds/TnTg1\region\r.0.0.mca): Permission denied in C:\Users\test\Desktop\new\plugins\pvp\src\pvp\Main.php on line 301Warning: rmdir(C:\Users\test\Desktop\new\/worlds/TnTg1\region): Directory not empty in C:\Users\test\Desktop\new\plugins\pvp\src\pvp\Main.php on line 306Warning: rmdir(C:\Users\test\Desktop\new\/worlds/TnTg1): Directory not empty in C:\Users\test\Desktop\new\plugins\pvp\src\pvp\Main.php on line 306 In my understanding I believe this happens due to the server software dealing with a different world format. But I am not so sure. The code to delete the directory is as follows, can anyone see where im going wrong? PHP: public function deleteDirectory($dirPath) { if (is_dir($dirPath)) { $objects = scandir($dirPath); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dirPath . DIRECTORY_SEPARATOR . $object) == "dir") { $this->deleteDirectory($dirPath . DIRECTORY_SEPARATOR . $object); } else { unlink($dirPath . DIRECTORY_SEPARATOR . $object); } } } reset($objects); rmdir($dirPath); } } Thanks, MC ATECH
nope, the php process just doesn't have enough rights to delete the file, hence "Permission denied" Check file permissions.
well, basically you need to check file permissions. As I do not have access to a windows pc currently (linux rules!) I can't provide you with screenshots, maybe someone else can or simply google "change permissions of folders recursively windows"
This will work on windows: PHP: public function deleteDirectory($dirPath) { system("del /q ".$dirPath);}
Scary stuff, I wouldn't run anything using system that accepts input. You could try to disable UAC in Windows to see if it makes a difference. Personally whenever _anything_ happens on the C drive, my Windows 10 install gets very finicky about it.