Some times in application development, we required to delete files older than specified number of days. Actually below method removes older files from disk and free the hard disk memory.
Below example demonstrate how to delete files, older than specified number of days. This code delete files from specified directory only, not from child folders. deleteOldFiles() method takes three parameters first one is folder/directory path, second one is number of days and third parameter is return count.
Simple Method to Delete Files Older than n Number Of days
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.
I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.