/// <summary> /// Gets the public folder hierarchy /// </summary> private void GetPublicFolders() { ExchCmds powershell = null; try { powershell = new ExchCmds(Config.ExchangeURI, Config.Username, Config.Password, Config.ExchangeConnectionType, Config.PrimaryDC); // Get public folders List<BasePublicFolder> pf = powershell.Get_PublicFolderHierarchy(CPContext.SelectedCompanyCode, Config.ExchangeVersion); this.logger.Debug("Sorting public folder hierarchy for " + CPContext.SelectedCompanyCode); pf.Sort((pf1, pf2) => pf1.ParentPath.CompareTo(pf2.ParentPath)); foreach (BasePublicFolder p in pf) { this.logger.Debug("Processing public folder " + p.Path); if (p.ParentPath.Equals(@"\")) { TreeNode tmp = new TreeNode(); tmp.Text = " - " + p.Name; tmp.Value = p.Path; tmp.ImageUrl = "~/img/icons/16/folder.png"; treePublicFolders.Nodes.Add(tmp); } else { // It isn't a parent node so we need to find its parent then add it FindNode(treePublicFolders.Nodes, p); } } } catch (Exception ex) { notification1.SetMessage(controls.notification.MessageType.Error, ex.Message); } finally { if (powershell != null) powershell.Dispose(); } }