File cleanup
So you’re generating log files with all the output from your tests, showing passes and failures.
However, now everything is just building up and you’re ending up with tons of log files. It’s tedious to delete them all except the ones you want. So I wrote a little function that cleans up all but the current days log files.
public void deleteArchivedLogs()
{
string LogArchive = @"path\to\log\archive\folder";
//I used my resources to store a path and just accessed it using myRes.LogArchive
//But for this example, i changed it to use a string we set in this function
var files = new DirectoryInfo(LogArchive).GetFiles("*.*");
foreach (var file in files)
{
if (file.LastWriteTime < DateTime.Today) //if the file's modify date is older than today, delete the file
{
File.Delete(file.FullName);
}
}
}