List archive folders

GroupDocs.Viewer provides additional information such as list of folders when calling GetViewInfo method. To retrieve view information for Archive File call GetViewInfo method and cast output result to ArchiveViewInfo type.

Following example demonstrates how to print out archive contents.

public static void PrintViewInfo()
{
    using (Viewer viewer = new Viewer("sample.zip"))
    {
        ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView();
        ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions);

        Console.WriteLine("File type: " + viewInfo.FileType);
        Console.WriteLine("Pages count: " + viewInfo.Pages.Count);
        Console.WriteLine("Folders: ");
        Console.WriteLine(" - /");

        string rootFolder = string.Empty;
        PrintFolders(viewer, rootFolder);
    }
}

private static void PrintFolders(Viewer viewer, string folder)
{
    ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView();
    viewInfoOptions.ArchiveOptions.Folder = folder;

    ArchiveViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions) as ArchiveViewInfo;

    foreach (string subFolder in viewInfo.Folders)
    {
        Console.WriteLine($" - {subFolder}");
        PrintFolders(viewer, subFolder);
    }
}