Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: Order returned by DownloadFolders Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
rmcewen
Newbie
Newbie


Joined: 05 May 2007
Online Status: Offline
Posts: 2
Posted: 05 May 2007 at 2:08pm | IP Logged Quote rmcewen

Using the DownloadFolders method to return the folder list doesn't seem to return the folders in an order which makes it easy to organize the list (i.e. in a treeview). In my sample app, the folders are returned with all the level zero folders first, followed by the level 1's and so on. So I can't iteratively or recursively build a folder structure without actually parsing the folder names to determine the parent of each subfolder.

Does anyone know a better way to do this?
Back to Top View rmcewen's Profile Search for other posts by rmcewen
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 06 May 2007 at 8:24am | IP Logged Quote Alex

Approach #1 is iterating through returned FoldersCollection multiple times. On the first run, you create root entries (those which have Folder.NestingLevel=0).
With next runs, you create entries with NestingLevel = 1, 2, etc. To get parent folder name for folder which has NestingLevel > 0:
Code:

strParent = folder.Name.Substring(0, folder.Name.Length - (folder.ShortName.Length + folder.Delimiter.Length))


Approach #2 is downloading only 1 level of folders each time. Thus, you download root level folders only, and then (for instance, when it's desired to know what's in certain folder, you download its immediate subfolders, etc). See Imap.DownloadFolders for more information.

Regards,
Alex
Back to Top View Alex's Profile Search for other posts by Alex
 
rmcewen
Newbie
Newbie


Joined: 05 May 2007
Online Status: Offline
Posts: 2
Posted: 07 May 2007 at 11:31pm | IP Logged Quote rmcewen

Thanks.

I implemented something similar to your Approach #1 except instead of iterating multiple times, I sort the folder list by NestingLevel before iterating through so all the parent folders are created before the children.
Back to Top View rmcewen's Profile Search for other posts by rmcewen
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide