The code below produces following output:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs
C:\ProgramData\Microsoft\Windows\Start Menu\Programme (Localized German)
Problem: These are both referring to the same directory but I can not call EnumerateFiles on the localized path (which wouldn't make sense anyway) because it produces an System.UnauthorizedAccessException and this also means I can not use EnumerateFiles with SearchOption.AllDirectories because I get the same Excepetion.
Is there a way to only get the functional non-localized paths out of EnumerateDirectories?
//Root Directory is C:\ProgramData\Microsoft\Windows\Start Menu
foreach(DirectoryInfo directoryInfo in rootDirectory.EnumerateDirectories("*", SearchOption.TopDirectoryOnly))
{
Console.WriteLine("Dir: " + directoryInfo.FullName);
//C:\ProgramData\Microsoft\Windows\Start Menu\Programme
//C:\ProgramData\Microsoft\Windows\Start Menu\Programs
foreach (FileInfo fileInfo in directoryInfo.EnumerateFiles("*", SearchOption.TopDirectoryOnly))
{
//do stuff
}
}