There are no answers from anyone else, so here is what I did:
- I made sure that I use CustomDictionaries.Remove in all text boxes with custom dictionaries before closing the form in which they are located. This eliminates new entries in _GLOBAL_ and related files in AppData \ Local \ Temp.
But there will be times when everything goes wrong, or the user just finishes the task, leaving the _GLOBAL_ and .dic entries in place, therefore:
I decided to go further. When I launch my application, I will not only clean the entries in _GLOBAL_ that do not have the corresponding files (as suggested in the previous publication mentioned above), but also to delete all entries related to the .dic files in AppData \ Local \ Temp. My theory is that anyone who left notes there didnβt mean it, otherwise they would probably have saved the .dic file in another folder (as Microsoft Office does).
try { string[] allDictionaries = (string[])Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Spelling\Dictionaries", "_Global_", new string[0]); if (allDictionaries.Count() > 0) { List<string> realDictionaries = new List<string>(); bool changedSomething = false; foreach (string thisD in allDictionaries) { if (File.Exists(thisD)) { if (thisD.Contains(@"\AppData\Local\Temp\")) {
I'm still wondering if it is possible to completely clear the entries in _GLOBAL_, which refer to the files in AppData \ Local \ Temp. Of course, people should not leave important things in a temporary folder ... should they?
What would be very nice is an overload in CustomDictionaries.Add, which allows us to set the name and folder of the .dic file, allowing all text fields in the same application to share the same .dic file and make sure that we do not leave a load of redundant entries and files with seemingly random names hanging in the first place ..... please Microsoft.
source share