Hi. This is a simple program, though it looks long. All i have done is created 2 Directories. In the Directory1, I have created 3 files, and deleted the second directory. I have then renamed the Directory1 and tried to Delete it after Deleting the files( as directories won't be deleted unless they are empty. How ever, for some reason my files arent gettting deleted due to which the directory is not getting Deleted. I am not sure where the problem. Could it be because when I have created a file , i have created it in the Directory1 folder and not the renamed Directory. That was just a guess.
Here is the code. Hope some one can help me out. Thanks.
The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Joined: May 09, 2004
Originally posted by Nabila Mohammad: Could it be because when I have created a file , i have created it in the Directory1 folder and not the renamed Directory. That was just a guess.
That is correct. To see what happens, use a print statement:
It will print the file name and the result of the delete() call. To remove files from the renamed directory, use the list() or listFiles() methods of the File class.