I am using a FileSystemWatcher to check if new directories are created in the watched one. If the user creates it per Explorer -> Rightclick -> New Folder at first a directory "New Folder" is created that the user can rename instantly. Nevertheless I get the Created event on "New Folder", which I can handle. My problem is that running the software differently localized Windows machines makes it impossible to check against "New Folder". How can I get the name of new folder as used by the explorer in the current language.
Thanks.
See these:
What you need to do is discover the "ID" of the string that is used for "New Folder"....then you can use LoadString
to load it from the string table resource inside Shell32.dll
.
However, the ID isn't necessarily stable and has changed between editions of Windows.
For instance...XP has the string table set up as follows:
On Windows 7 64 bit...the "New Folder" string has an ID of 16888.
You can try 2 different ways to do this ID discovery:
You would need to write a utility that just called this function on each English/US edition of Windows (XP, Vista, Windows 7, etc)...to find out the ID.
UINT new_folder_id = FindResourceStringId(shell_handle, L"New Folder", 0x409);
You can then do a switch inside your code that used the correct ID depending on the current version of Windows that is running.
By looking up the "New Folder" string in the English resource to find its ID. However this would need the English MUI language pack to be installed on the system.
Use this C# code to load a particular "string" given a particular ID.
To test if your code is working....you could install the MUI language packs and could then attempt to load the string for a different locale.
Alternatively you could use SHChangeNotifyRegister
to listen to changes made "in the shell"...Explorer
calls SHChangeNotify
when it does certain things.
Use the code here:
Use the suitable flags e.g. SHCNRF_ShellLevel, SHCNE_MKDIR.