String deleteString = e.getPath();
                                    File deleteListFile = new File(deleteString);   
                                    
                                    
                                        deleteListFile.delete();

so to talk you through it, the File object is obtained by the results by system.out.println (not shown here)

...and then I am getting the path of the file by using getpath()

then i want that file path and its file deleted, but wen i go check in that folder its not deleted.

The list of files mathcing the criteria are listed correctly because they get displayed, just not deleted..

Help??

Recommended Answers

All 7 Replies

come on please!

commented: Don't nag, we will help as soon as we can. +0

Is this File object a directory? If so it must be empty to be deleted. The only other thing I can think of if this is not a directory is that maybe your issue has to do with file permissions?

EDIT: And don't get impatient, we will help as soon as we can!

hmm nope, ive set up if statements not to inlcude direcories, i just added a system.out.println to states that the deletion process is in progess but that message doesnt even show up, im just going to have fun with trial and errror

This means your program is getting stuck up at some place, so there may be some exception causing this. Put a try-catch block and print a stack trace in the catch clause, you will soon know what happens.

hi thanks for the reply

i changed it to abosulte path instead but tha tdidnt have an effect so i changed it back, then I checked if the objects existed by using .exists() and getting that printed out by the system, and the results were true

i mananged to get the message up to so i dont think its gettting stuck now, but the files are still not getting deleted. and there not system files just images.

But you are still missing two points here. One, that you aren't still catching any exceptions that might occur during such an operation. Only taking the SOP statement up will not work, rather it won't cause any difference. Second, What do you think the program will do if you do not have permission over the files you are deleting, it's going to throw an exception which you are ignoring altogether.

lol i will add the try and catch if it works, im testing it in a small direcotry first, ive had no exceptions yet, but i will add try and catch it works with even an exception

just some more info:

the system.out.println gets its information form an input stream, and there is more than one file to delete

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.