I am having an issue with creating my Registry key. When I try to create it I get an error message saying: System.UnauthorizedAccessException: Access to the registry key 'HKEY_CLASSES_ROOT\PHPFiles' is denied.
Here is the code:
var menuName = @"PHPFiles";
var command = @"PHPFiles\DefaultIcon";
RegistryKey regmenu = null;
RegistryKey regcmd = null;
try
{
regmenu = Registry.ClassesRoot.CreateSubKey(menuName);
if (regmenu != null)
regmenu.SetValue("", "PHP Server Side Document");
regcmd = Registry.ClassesRoot.CreateSubKey(command);
if (regcmd != null)
regcmd.SetValue("", @"C:RegistryIcons\PhpFile.ico");
}
How can I add my permissions to the registry code?