I'm trying to delete a file using File.delete(), but it keeps returning false. I've verified that path to the file is correct and that the permissions on the file allow deleting, but it still doesn't work. Any ideas? The routine follows.
There's nothing more dangerous than a resourceful idiot. ---Dilbert
Have you checked on permissions (write access) on directory where file resides? Now I'll take a look at the code. How was tempFile created in the first place? -Barry [ August 13, 2002: Message edited by: Barry Gaunt ]
If you get "reason unknown", check to see if you've opened any input or output streams to the file in question, and make sure that you close the streams properly before you try to delete the file. [ August 13, 2002: Message edited by: Jim Yingst ]
Jim, I once played around with File.createTempFile() and the deleteOnExit() method. At that time I could never get the file automatically deleted. That was on NT or Windows 2000. Did you ever hear about any such problem? -Barry [ August 13, 2002: Message edited by: Barry Gaunt ]
Here's what I've discovered: The file name is retrieved from a table when the user clicks on it. If a single or double-click is done, the row is selected and the file name is returned, but for some reason the file is not deleted. A long click (not quite a second) on the file name both returns the correct name and allows the file to be deleted. Very strange.
There's nothing more dangerous than a resourceful idiot. ---Dilbert