I am trying to change the location of windows specials folders (documents, downloads, pictures, etc.) from windows registry:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

But, these are not taking any effect to actual locations of the special folders.

How I can change it programmatically?
I have tried to change it like this in registry.
string root = SID + "\\" + @"Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders";
try
{
RegistryKey foldersKey = Registry.Users.OpenSubKey(root, true);
if (foldersKey != null)
{
foldersKey.SetValue("{374DE290-123F-4565-9164-39C4925E467B}", AppHelper.GetApplicationUserProfile() + @"\Downloads");
foldersKey.SetValue("Personal", AppHelper.GetApplicationUserProfile() + @"\Documents");
foldersKey.SetValue("My Music", AppHelper.GetApplicationUserProfile() + @"\Music");
foldersKey.SetValue("My Pictures", AppHelper.GetApplicationUserProfile() + @"\Pictures");
foldersKey.SetValue("My Video", AppHelper.GetApplicationUserProfile() + @"\Videos");
//foldersKey.SetValue("Desktop", AppHelper.GetApplicationUserProfile() + @"\Desktop");
foldersKey.SetValue("Favorites", AppHelper.GetApplicationUserProfile() + @"\Favorites");
foldersKey.Close();
}
}
catch (Exception e)
{
Logger.Error(e);
}
I would like to change the location of special folders in file explorer, when ever the registry path of these folders are changed. How I can do this in my C# code?