I am trying to make a program that backs up folders. I want to have say 5 folders, then if it is backed up again I want the oldest of the 5 folders to be deleted and the new one placed in it.
How would I find the oldest folder in a directory
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using System.IO.DirectoryInfo could be helpful.
Specifically with regards to the
CreationTimeproperty andEnumerateDirectoriesmethod.Here is a modified sample for the EnumerateDirectories method using LINQ:
Here is a non LINQ version to get the oldest directory in a folder: