Pablo Honey
Pablo Honey

Reputation: 1096

Confusing naming convention for Environment.SpecialFolder

I found that on a 64 bits system:

   Environment.GetFolderPath(Environment.SpecialFolder.SystemX86);

Returns actually %windir%/SysWow64 and :

   Environment.GetFolderPath(Environment.SpecialFolder.System);

returns %windir%/system32

Why did they use this confusing naming convention ?

Upvotes: 0

Views: 81

Answers (1)

Dan Wilson
Dan Wilson

Reputation: 4047

The short answer is compatibility. See this article.

This may seem a bit illogical if you look at the folder names, but there is an explanation to this. It has to do with compatibility. Many developers have hard coded the path to the system folder in their applications source code. They have included "System32" in the folder path. And to preserve compatibility, if the application is converted to 64-bit code, the 64-bit system folder is still named System32.

But what about 32-bit applications that have the system path hard coded and is running in a 64-bit Windows? How can they find the new SysWOW64 folder without changes in the program code, you might think. The answer is that the emulator redirects calls to System32 folder to the SysWOW64 folder transparently so even if the folder is hard coded to the System32 folder (like C:\Windows\System32), the emulator will make sure that the SysWOW64 folder is used instead.

Upvotes: 1

Related Questions