I am writing a utility that should create a list of all registry values ββin HKCR. I do this with a recursive function:
var list = new Dictionary<string, string>(); Read(Registry.ClassesRoot, list); static void Read(RegistryKey root, IDictionary<string, string> values) { foreach (var child in root.GetSubKeyNames()) { using (var childKey = root.OpenSubKey(child)) { Read(childKey, values); } } foreach (var value in root.GetValueNames()) { values.Add(string.Format("{0}\\{1}", root, value), (root.GetValue(value) ?? "").ToString()); } }
This works fine, but it takes a good chunk of time (20 seconds on my PC). Is there a faster way to do this, or is it as good as it gets?
Jon b source share