So i'm checking to see if I have write access to the registry with the code below
try
{
RegistryPermission perm = new RegistryPermission(RegistryPermissionAccess.Write, networkRegistryPath);
perm.Demand();
}
catch (Exception ex)
{
throw new ArgumentException("Write Access Denied");
}
rk.SetValue("PnPCapabilities", powerOff[0]);
networkCards.Add(networkRegistryPath, powerOff[0]);
if perm.Demand() failed I'd assume it would throw an error but it doesn't so I then try to write a value. It then errors with Cannot write to registry.
I put the rk.SetValue in the catch as well but I don't think I should have needed to because i'm checking before hand if I have the ability to write.
Am I missing something here?