Globals.RegistryAccess.copyKey C# (CSharp) Method

copyKey() public static method

Copy a registry key. The parentKey must be writeable.
public static copyKey ( RegistryKey parentKey, string keyNameToCopy, string newKeyName ) : bool
parentKey Microsoft.Win32.RegistryKey
keyNameToCopy string
newKeyName string
return bool
        public static bool copyKey(RegistryKey parentKey, string keyNameToCopy, string newKeyName)
        {
            //Create new key
            RegistryKey destinationKey = parentKey.CreateSubKey(newKeyName);

            //Open the sourceKey we are copying from
            RegistryKey sourceKey = parentKey.OpenSubKey(keyNameToCopy);

            recurseCopyKey(sourceKey, destinationKey);

            destinationKey.Close();
            sourceKey.Close();
            return true;
        }