Category Archives: Registry

Read & Write to System Registry data, keys using C#

In this post i am going to explain that how to access the System Registry and how to read and write data to registry.

Step 1: First you need to import the below namespaces:
using Microsoft.Win32;

Step 2: Now create an object of Registry class:
RegistryKey regkey;

Step 3: Now access the registry and get the value of a key

regkey = Registry.CurrentUser.CreateSubKey(@”Software\Microsoft\FTP”);

if (regkey.GetValue(“Use PASV”) == null)
txtValue.Text = “No Value Specified”;

txtValue.Text = regkey.GetValue(“Use PASV”).ToString();

The above code gets the value of the “Use PASV” key from the
Registry\CurrentUser\Software\Microsoft\FTP path.

Step 4: Set the key value
regkey.SetValue(“Use PASV”, txtValue.Text);