Where is the Problem- Not able to delete files of folder, No error also.
Hi Friends,
I has written this follwoing code to delete files of a particular folder. Here attachmentFolder is a folder. I m listing all the files of this directory, n i m deleting all the files.
Here i m getting correct count for the no of files in directory, but sometimes it deletes the file sometime not.
File attachmentFolder =new File(parentFolder);
System.out.println("Attachment Folder Name is : "+attachmentFolder.getAbsolutePath());
if(attachmentFolder.isDirectory()){
File[] files = attachmentFolder.listFiles();
System.out.println("No of Files For Attachments are: "+files.length);
for(int i=0; i<files.length; i++ ){
files[i].delete();
}
}
System.out.println("All attachments Deleted");
Can somebody tell me what could be the possible problem?
Some times it deleted some files only, also there is no error. I had written this in try-catch, it is also not giving any problem. File may be of any type but not folders in attachmentFolder.
Thanks in advance.>

