For cleaning up the test files, am trying to do the below. But its not clearing the files as well as not generating an error.
Am I missing something obvious?
private void CleanUpTempDirFiles()
{
var fileGenerationDir = new DirectoryInfo(Path.Combine(Path.GetTempPath(), "TestFilesDir"));
fileGenerationDir.GetDirectories().ToList().ForEach(dir => dir.GetFiles().ToList().ForEach(file => file.Delete()));
}
You can get all the files in all the the subdirectories using SearchOption.AllDirectories