• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Enumerate Folders

Enumerates the folder hierarchy of a PST file.

Code

using DRIT.Mail.Pst.PhysicalLayout;

using var pst = new PstFile("archive.pst");

void PrintFolders(Folder folder, int depth)
{
    string indent = new string(' ', depth * 2);
    Console.WriteLine($"{indent}{folder.Name} ({folder.MessageCount} messages)");

    foreach (var child in folder.SubFolders)
    {
        PrintFolders(child, depth + 1);
    }
}

PrintFolders(pst.Folders.Root, 0);

Remarks

The folder hierarchy is rooted at pst.Folders.Root. Use GetAllFoldersFlatDepthFirst() to iterate all folders without recursion.

  • Improve this Doc
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX