Changing the locations of shell folders from registry paths is not taking effect

73 Views Asked by At

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

enter image description here

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

enter image description here

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?

0

There are 0 best solutions below