• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reasons File.delete() won't work?  RSS feed

 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try:

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 ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Barry- sounds vaguely familiar... ah, here we are. Allegedly fixed now.
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Figured it out. There's an actionListener attached to the table that's causing a problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!