I'm currently tossed into having to try and create a sort of housekeeping utility that we can set up scheduled tasks to run.
I've got it working hardcoded to delete from a specific folder and it deletes everything that's older than 7 days.
I would like some flexibility so I don't have to create a new program everytime we find a new dir that we need to housekeep.
I would like to have a configuration.txt file containing two lines, one being Directory of where to look and delete files and the other line being files older than: x days
I can read the file good enough, I'm just not certain how I would go about creating the strings from the text file.
Below is my current working program, it's really basic stuff.
var files = new DirectoryInfo(@"c:\log").GetFiles("*.log")
foreach (var file in files)
{
if (DateTime.UtcNow - file.CreationTimeUtc > TimeSpan.FromDays(7))
{
File.Delete(file.FullName);