Hello All,
I want to delete all files in a directory. I am making a backup copy of all
files in the directories say c:\abc by reading and writing to a file. After
making a backup copy I want to delete these files. I am using following
code:
// get list of all files in the directories
File f = new File(sdir);
if(f.isDirectory()) {
sfiles = f.list();
}
for(int u=0;u<sfiles.length;u++) {
new File(sfiles[u]).delete();
}
The programm does not delete files from the directory. Can anyone tell me
how I can delete these files from the java programm. I used a trick on
windows2000, I created a bactch file to delete these files and created a new
child process(executed bacth file). This solution works fine on windows2000.
But on WindowsNT, the JVM can not create child process. So the files can not
be deleted.
Could you Java Gurus help me to solve this probem?
Thankx in advance.
Manmohan