Used .renameTo instead of .canWrite to check if file is unlocked

This commit is contained in:
coolGi
2023-10-06 18:02:28 +10:30
parent 820683783b
commit 417cf0a891
@@ -22,7 +22,7 @@ public class DeleteOnUnlock
{
for (int i = 0; i < 600; i++) // As it rests for around 0.1 second each loop, this should last a minute
{
if (file.canWrite())
if (file.renameTo(file)) // If it is able to be renamed, then it is unlocked and can be deleted
{
Files.delete(file.toPath());
break;