I need to change some network settings with my C# program. I wrote the following function:
public void Write_to_reg(string id, string KeyName, string Value)
{
RegistryKey regKeyAppRoot = Registry.CurrentUser.CreateSubKey(strTargetReg + "\\" + id);
try
{
regKeyAppRoot.SetValue(KeyName, Encoding.ASCII.GetBytes(Value));
}
catch (Exception e)
{
MessageBox.Show("Error! Please Try Again. " + e.Message , "Settings Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
I am able to modify the "IPAddress" field, but when I try to modify the "DefaultGateway", and "NameServer" fields I don't get any errors, but the values do not change. What am I doing wrong?
I am actually trying to blank out those 2 fields.
Thanks, Tim