Author |
|
rmcewen Newbie
Joined: 05 May 2007
Online Status: Offline Posts: 2
|
Posted: 05 May 2007 at 2:08pm | IP Logged
|
|
|
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 |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 06 May 2007 at 8:24am | IP Logged
|
|
|
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 |
|
|
rmcewen Newbie
Joined: 05 May 2007
Online Status: Offline Posts: 2
|
Posted: 07 May 2007 at 11:31pm | IP Logged
|
|
|
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 |
|
|