/// <summary> /// Finds the last folder. /// </summary> /// <param name="folder">The folder.</param> /// <param name="path">The path.</param> /// <param name="delim">The delim.</param> /// <param name="pattern">The pattern.</param> /// <returns></returns> private static Folder FindFolderByPattern(Folder folder, string path, char delim, string pattern) { Folder retVal = null; TreeService tree = folder.GetTreeService(); //recursion end point if (pattern.Equals(path, StringComparison.InvariantCultureIgnoreCase)) { return(folder); } foreach (TreeNode node in tree.GetChildNodes()) { String folderPath = path + delim + ((Folder)node.InnerObject).Name; if (retVal != null) { break; } if (pattern.StartsWith(folderPath, StringComparison.InvariantCultureIgnoreCase)) { retVal = FindFolderByPattern((Folder)node.InnerObject, folderPath, delim, pattern); } } return(retVal); }