Handle Deleting Folders Better

This commit is contained in:
Konloch 2024-10-02 12:54:17 -06:00
parent 23c125cacd
commit 95da798c58

AI 샘플 코드 생성 중입니다

Loading...

View File

@ -64,16 +64,28 @@ public class TempFile
toDelete.delete();
if(!toDelete.getParentFile().getAbsolutePath().equalsIgnoreCase(new File(TEMP_DIRECTORY).getAbsolutePath()))
{
toDelete.getParentFile().delete();
}
deleteFolder(toDelete.getParentFile());
}
//delete parent if it's not the main temp directory
if(!getParent().getAbsolutePath().equalsIgnoreCase(new File(TEMP_DIRECTORY).getAbsolutePath()))
deleteFolder(getParent());
}
private void deleteFolder(File file)
{
File[] files = file.listFiles();
if(files != null)
{
getParent().delete();
for(File subFile : files)
{
if(subFile.isDirectory())
deleteFolder(subFile);
}
}
file.delete();
}
public File createFileFromExtension(String extension)