I am getting error cannot write to the registry key when i am trying to save my keys in the registry .
//Here is my code .
Note : I tried to run as an Admin
You are probably falling foul of registry redirection. Perhaps you have a 32 bit process on a 64 bit system and writes to HKLM\Software get redirected to HKLM\Software\Wow6432Node.
You need to open the 64 bit key directly, or compile for AnyCPU.