private void buttonOK_Click(object sender, EventArgs e) { string key = textBox1.Text; int num = 0; string tempKey = key; while (GroupsManager.GetGroup(tempKey) != null) { tempKey = key + " (" + ++num + ")"; } key = tempKey; GroupsManager.AddGroup(key, chkAllTabs.Checked ? Tabs.Select(item => item.CurrentPath) : new string[] { newPath }); }