/// <summary> /// Remove paths that don't exist or are listed multiple times /// </summary> private void Clean_Click(object sender, RoutedEventArgs e) { lock (stateLock) { var sp = SystemPath.Select(_ => _.Path); var up = UserPath.Select(_ => _.Path); var cp = sp.Concat(up); var s = sp.Where((p, index) => p.Exists && !sp.Take(index).Contains(p)); var u = up.Where((p, index) => p.Exists && !cp.Take(sp.Count() + index).Contains(p)); SetPaths(s, u); } }