---
title: "Create, read, write and delete from registry using C#"  
description: "In this blog, I’m explaining how to create a key in registry from C# application and how to read, write and delete it.  CreateRegistryKey key = Regist"  
author: "Sumit Kesarwani"  
published: 2013-11-14  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/610/create-read-write-and-delete-from-registry-using-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Create, read, write and delete from registry using C#

In this [blog](https://www.mindstick.com/articles/12705/myths-and-misconception-about-blog), I’m explaining how to create a key in registry from C# [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) and how to read, write and [delete](https://www.mindstick.com/forum/33620/how-to-delete-record-from-list-in-mvc-using-ajax) it.\

##### Create

RegistryKey key = Registry.CurrentUser.CreateSubKey(@"[SOFTWARE](https://www.mindstick.com/articles/311636/best-freelancing-websites-to-get-software-development-services)\TESTINGREGISTRYKEY", RegistryKeyPermissionCheck.ReadWriteSubTree);

This statement will create a key in registry.

##### Write

Once you have created a key in registry, now you want to write a [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) in it but before you write the key, you have to open it like this:

RegistryKey key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\TESTINGREGISTRYKEY", RegistryKeyPermissionCheck.ReadWriteSubTree);

This statement open the key for you and now you have the [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) to the key.

key.SetValue("NotificationStatus",true);

This statement will write the value ‘true’ with name ‘NotificationStatus’.

##### Read

Now you have written the key value in registry and you want read it.

You can write the following statement to get the value from the key value in registry.

object flag = key.GetValue("NotificationStatus");

I have taken a [object type](https://www.mindstick.com/blog/398/difference-between-object-type-and-var-type) [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation) to receive the value coz the GetValue [method returns](https://www.mindstick.com/forum/12904/main-method-returns-if-submethod-has-stoped-by-return-in-c-sharp) the object type value.

##### Delete

key.DeleteValue("NotificationStatus");

This statement deletes the key value from the registry.

---

Original Source: https://www.mindstick.com/blog/610/create-read-write-and-delete-from-registry-using-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
