I have written a sample application to debug an issue with enumerating files.
Enumerating a directory with a local path (eg C:\Data\MAN) enumerates considerably quicker than a shared directory with a UNC path (eg \\MACHINENAME\man). Even though these paths both point to the same directory on the local machine.
With 72000 files, this takes approx 10 seconds:
DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\Data\MAN");
FileInfo[] fileInfoTest = directoryInfo.GetFiles("*.*",
SearchOption.AllDirectories);
With 72000 files, this takes approx 2 minutes: (where \\MACHINENAME\man is shared folder C:\Data\MAN)
DirectoryInfo directoryInfo = new DirectoryInfo(@"\\MACHINENAME\man");
FileInfo[] fileInfoTest = directoryInfo.GetFiles("*.*",
SearchOption.AllDirectories);
Is this amount of overhead expected when using a UNC path?