문제

In our application we are having different components and registry key will be created in component Name.

For ex.

We are having a component named Notification and we are having registry key as follows

RegistryKey rKeyNotification = Registry.LocalMachine.OpenSubKey("SOFTWARE\\CompanyName\\ProdName\\Notification");

Now i wanted to delete this key and all the subkeys.

I was trying to delete this rKeyNotification completely. But i don't find any way.

I was trying like follows.

if (rKeyNotification != null) {

   rKeyNotification.DeleteSubKeyTree("Notification");
}

But this piece will look for RegistryKey rKeyNotification =Registry.LocalMachine.OpenSubKey("SOFTWARE\\CompanyName\\ProdName\\Notification\\Notification");

There is no option like rKeyNotification.DeleteSubKeyTree()

Should i always go up one level (Registry.LocalMachine.OpenSubKey("SOFTWARE\\CompanyName\\ProdName) then only delete the key?

도움이 되었습니까?

해결책

There is no method to delete a key itself, but you can use Registry.LocalMachine directly:

string keyname = @"SOFTWARE\CompanyName\ProdName\Notification";
Registry.LocalMachine.DeleteSubKeyTree(keyname);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top