private static IEnumerable<string> GetAllSubPaths(string s) { int lastDotIndex; while ((lastDotIndex = s.LastIndexOf('.')) != -1) { yield return s; s = s.Substring(0, lastDotIndex); } yield return s; } }