0

I'm trying to access the directory C:\Windows\System32\winevt in my code, but I get a System.IO.DirectoryNotFoundException.

I read this thread: Anyone know why I can't access the winevt folder programmatically in C#?

This implies that running a 32-bit application under a 64 bit operating system will re-direct me to SystemWOW64 directory, and the resolution is to instead set my directory to %windir%\Sysnative\winevt. So I modified my code to conform to the answer provided in the aforementioned thread, except it still fails. I'm running windows 10 enterprise 64-bit and Sysnative doesn't exist.

Example Code:

This will return true:

            string directory = @"C:\Windows\System32";                  
            bool isDirectoryExists = Directory.Exists(directory);

This will return false:

            string directory = @"C:\Windows\System32\winevt";                  
            bool isDirectoryExists = Directory.Exists(directory);

There is no winevt directory in the directories System and SysWOW64, and Sysnative does not exist. So my question is, how do I get access to the winevt directory?

D. Foley
  • 1,034
  • 1
  • 9
  • 23

1 Answers1

0

My mistake was looking for an actual folder called Sysnative in the Windows directory, I did not see it and therefore assume the code would not work. However I tested it anyway and Directory.Exists returned true. This is because Sysnative is a virtual folder.

Returns true:

        string directory = @"C:\Windows\Sysnative\winevt";                  
        bool isDirectoryExists = Directory.Exists(directory);

http://www.thewindowsclub.com/sysnative-folder-in-windows-64-bit

D. Foley
  • 1,034
  • 1
  • 9
  • 23