| | |
Why doesn't this code delete a file? Help me troubleshoot
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 37
Reputation:
Solved Threads: 0
Java Syntax (Toggle Plain Text)
String deleteString = e.getPath(); File deleteListFile = new File(deleteString); deleteListFile.delete();
...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??
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!
EDIT: And don't get impatient, we will help as soon as we can!
Last edited by darkagn; Mar 13th, 2009 at 12:09 pm.
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. 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.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
•
•
Join Date: Nov 2008
Posts: 37
Reputation:
Solved Threads: 0
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.
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.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
•
•
Join Date: Nov 2008
Posts: 37
Reputation:
Solved Threads: 0
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
just some more info:
the system.out.println gets its information form an input stream, and there is more than one file to delete
![]() |
Similar Threads
- Hidden program installs .dlls with randomly generated names in random "notify" reg. (Viruses, Spyware and other Nasties)
- power failure during printing leads to loss of printer subsystem? (Windows NT / 2000 / XP)
- file read and buffer problems (C++)
- Calling Matlab functions from VS.NET (C)
- Nasty guard.tmp :( (Viruses, Spyware and other Nasties)
- Unknown Virus (Viruses, Spyware and other Nasties)
Other Threads in the Java Forum
- Previous Thread: Enumerating permutations
- Next Thread: The better Java book?
| Thread Tools | Search this Thread |
-xlint android api applet application array arrays automation bi binary blackberry block bluetooth chat class classes client code compile compiler component database developmenthelp draw eclipse error event exception fractal freeze game gameprogramming givemetehcodez graphics gui html ide image input integer j2me j2seprojects java javac javaprojects jetbrains jni jpanel jtable julia learningresources lego linux list login loop loops mac map method methods mobile netbeans newbie notdisplaying number online oracle page print problem program programming project qt recursion scanner screen server set singleton size sms sort sql string swing system template textfields threads time title tree tutorial-sample update variablebinding windows working xor





