Re: Problem deleting file
CBO wrote:
Hi all,
I am currently developing a java application that uses a CSV file
which it reads and then populates the items inside a JList. Then the
user is able to delete an item from JList which then writes the
information to a temporary file. Once the data has been written I then
want the original file that it read in to be deleted. However for some
reason it keeps on failing and saying the deletion failed but I do not
understand. Below is the code that I am using in order for the item to
be removed from the JList and then written a the file with the new
information and also with the function where it is deleting the file:
[snip]
For some reason when the file gets deleted it keeps on going into the
same part of the program where it says:
if (!success){
System.out.println("Deletion failed.");
statusBar.setForeground(Color.red);
statusBar.setText("Unable to modify changes. Changes have not
taken affect. ");
}
I cannot work ou the reason for this.
Any help in this matter would be highly appreciated.
Thank you
Most likely something to do with what you haven't shown us.
For example, do you have the necessary permission from the OS/filesystem to
delete the file? You say you read the existing contents from the file, do you
close it afterwards - Windows won't let you delete an open file.
--
Nigel Wade