When running the following code:
var files = dir.EnumerateFiles("*.*", SearchOption.AllDirectories).Where(f => ext.Contains(Path.GetExtension(f.FullName))) foreach (FileInfo file in files) { file.CopyTo(destPath, true); } Where dir is a DirectoryInfo
Where ext is a List of strings containing accepted file extensions
Upon getting to the foreach loop, files is null.
Inside the foreach (at the in statement), the program jumps back to the => statement then fills files. When it's done, it skips over the foreach loop and never enters it.
I am lost here. Why is my code jumping one line back? I tried Enumerate and GetFiles, none seem to work.