Hi all,
I own a Nokia N95 and I implemented a j2me function to delete a folder stored on the memory card (E: drive).
In case the folder is empty, the function works.
Otherwise, should not the folder be empty, I delete all of the files in folder and then I delete the folder itself.
Files are correctly deleted and the directory becomes empty (if I open the memory card, I find the empty folder) but despite it, when I try to delete the folder, the following exception occurs: "Directory is not empty".
Has anyone suggestions on how to solve this problem?
Thanks in advance.
Cheers
try
{
String dir = "file:///E:/Dir/dir_to_delete";
FileConnection fileToDelete = (FileConnection) Connector.open(dir ,Connector.READ_WRITE);
if (fileToDelete.exists())
{
fileToDelete.setWritable(true);
Enumeration e = fileToDelete.list();
form.append("allora \n");
while(e.hasMoreElements())
{
String file_2 = (String)e.nextElement();
FileConnection file = (FileConnection) Connector.open(dir + "/" + file_2 ,Connector.READ_WRITE);
file.setWritable(true);
form.append("Sono dentro\n");
form.append("Elemento: " + file_2 + "\n");
file.delete();
file.close();
}
form.append("ESISTE \n");
fileToDelete.delete();
fileToDelete.close();
}
}
catch (IOException e)
{
form.append("Errore : " + e.getMessage());
}

Reply With Quote

