Perhaps you also have what I have: a directory name contains some unusual characters. In my case
Could not find a part of the path 'C:\Web\metBoot\wild iis\DigiCertยฉ Certificate Utility for Windows_files'.
This copyright mark is a problem.
So, using concepts made from Getting the short file name 8.3 from the long file name , I first convert my paths to short form and then use this to get the list of files.
StringBuilder sf = new StringBuilder(300); int n = GetShortPathName(sourceFolder, sf, 300); if (0 == n) { tk.write(Marshal.GetLastWin32Error().ToString()); continue; }
...
IEnumerable<string> fileGroup = Directory.EnumerateFiles(sf.ToString(), ext);
source share