Hello,
For some reason, I ran into peculiar situation sometimes delete() works, and other times it doesnt, especially when I put the code snippet as part of a bigger application. I just wonder if anyone have similar experience.
Example:
....
String fileName=(String)listbox.getSelectedValue();
System.out.println("file to be deleted= "+fileName);//printed filename correctly
File f = new File("c:\\temp", fileName);
System.out.println(f.delete());//printed 'false' even if the file is indeed in the c:\temp directory as specified, and it's not deleted
or in other simple case...
import java.io.*;
public class del {
public static void main(String args[]) {
File path = new File("c:\\temp");
File f=new File(path,"somefilename");
System.out.println(f.delete());//printed 'false' even if the file with "somefilename" exists in c:\temp
}}