/// <summary> /// Checks if the specified desktop exists. /// </summary> /// <param name="name">The name of the desktop.</param> /// <param name="caseInsensitive">If the search is case INsensitive.</param> /// <returns>True if the desktop exists, otherwise false.</returns> public static bool Exists(string name, bool caseInsensitive) { // enumerate desktops. string[] desktops = Desktop.GetDesktops(); // return true if desktop exists. foreach (string desktop in desktops) { if (caseInsensitive) { // case insensitive, compare all in lower case. if (desktop.ToLower() == name.ToLower()) { return(true); } } else { if (desktop == name) { return(true); } } } return(false); }