'System.IO.Directory.Exists always return false in subfolder of system32

I am using .NET Framework 4.8, trying to reach the winevt\Logs folder to get all available Event Logs on the Machine.

Code used is:

        const string logDirectory = @"C:\Windows\System32\winevt\Logs";
        if (Directory.Exists(logDirectory)) <-- always false even though directory exists?
        {
            Console.WriteLine("Directory exists");
        }

I've tried without "C:", without @ and with "\", with System.IO.Directory.Exists.

I am running as Admin and do not want to setup weird permissions - I guess it is a permissions thing.

How can I solve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source