N
N
NeoLight32020-08-25 13:02:31
C++ / C#
NeoLight3, 2020-08-25 13:02:31

How to save registry values ​​to a file in C#?

I made a small script that gets the names of the values ​​I need:

RegistryKey currentUserKey = Registry.CurrentUser;
                RegistryKey SOFTWARE = currentUserKey.OpenSubKey("SOFTWARE", true);
                RegistryKey SmartlyDressedGames = SOFTWARE.OpenSubKey("Smartly Dressed Games", true);
                RegistryKey Unturned = SmartlyDressedGames.OpenSubKey("Unturned", true);
                string[] key_names = Unturned.GetValueNames();
                for (int key = 0; key < key_names.Length; key++)
                {
                    string key_name = key_names[key];
                    string[] savings = { "barricades", "bans", "clothes", "inventory", "lastBackpack", "lastHat", "lastItem", "lastPants", "lastShirt", "lastState", "lastVest", "life", "position", "skills", "structures", "vehicles" };
                    for (int _saving = 0; _saving < savings.Length; _saving++)
                    {
                        string saving = savings[_saving];
                        if (key_name.StartsWith(saving))
                        {
                            Console.WriteLine(key_name);
                            var subkey = Unturned.OpenSubKey(key_name);
                            
                        }
                    }
                }

1. How to get the value of the registry by the name of the value (get the object of the RegistryKey class by the name of the value)?
2. How to save these values ​​to a file, so that later they can be retrieved from it back into the RegistryKey object?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question