Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Solution For A Common Problem: "Cannot Write To The Registry"

DZone's Guide to

Solution For A Common Problem: "Cannot Write To The Registry"

·
Free Resource
Original (not working):

 RegistryKey reg = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop");
 reg.SetValue("WallpaperStyle", "1");    //2 for stretch



Modified (working):

 RegistryKey reg = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);
 reg.SetValue("WallpaperStyle", "1");    //2 for stretch

 
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}