internal void CreateKey(string p_SubKeyName) { // Create a key Generic.SortedList <string, string> InitalValues = new Generic.SortedList <string, string>(); string[] SubKeys; string SubKey; int i, j; try { GetProfileMutex("CreateKey", p_SubKeyName); sw.Reset(); sw.Start(); // Start timing this call TL.LogMessage("CreateKey", "SubKey: \"" + p_SubKeyName + "\""); p_SubKeyName = Strings.Trim(p_SubKeyName); // Normalise the string: SubKeys = Strings.Split(p_SubKeyName, @"\", Compare: Microsoft.VisualBasic.CompareMethod.Text); // Parse p_SubKeyName into its elements switch (p_SubKeyName) { case "" // Null path so do nothing : { break; } case @"\" // Root node so just create this : { if (!FileStore.Exists(@"\" + VALUES_FILENAME)) { TL.LogMessage(" CreateKey", @" Creating root key ""\"""); InitalValues.Clear(); // Now add the file containing the contents of the key InitalValues.Add(COLLECTION_DEFAULT_VALUE_NAME, COLLECTION_DEFAULT_UNSET_VALUE); WriteValues(@"\", ref InitalValues, false); // Write the profile file, don't check if it already exists } else { TL.LogMessage(" CreateKey", " Root key alread exists"); } break; } default: { for (i = 0; i <= SubKeys.Length - 1; i++) { SubKey = ""; for (j = 0; j <= i; j++) { SubKey = SubKey + @"\" + SubKeys[j]; } if (!FileStore.Exists(SubKey + @"\" + VALUES_FILENAME)) { FileStore.CreateDirectory(SubKey, TL); // It doesn't exist so create it InitalValues.Clear(); // Now add the file containing the contents of the key InitalValues.Add(COLLECTION_DEFAULT_VALUE_NAME, COLLECTION_DEFAULT_UNSET_VALUE); WriteValues(SubKey, ref InitalValues, false); // Write the profile file } } break; } } sw.Stop(); TL.LogMessage(" ElapsedTime", " " + sw.ElapsedMilliseconds + " milliseconds"); } finally { ProfileMutex.ReleaseMutex(); } }