public static void CopyTree(this IVsWritableSettingsStore writableSettingsStore, SettingsStoreSubCollection from, SettingsStoreSubCollection to) { ThreadHelper.ThrowIfNotOnUIThread(); writableSettingsStore.CopyProperties(from, to); var fromStore = from.Root.SettingsStore; var fromPath = from.Path; for (uint index = 0; ; index++) { if (ErrorHandler.Failed(fromStore.GetSubCollectionName(fromPath, index, out var name))) { break; } var newSubCollection = new SettingsStoreSubCollection(to, name); ErrorHandler.ThrowOnFailure(writableSettingsStore.CreateCollection(newSubCollection.Name)); writableSettingsStore.CopyTree(new SettingsStoreSubCollection(from, name), newSubCollection); } }