How to display zip/rar content with html format

I am working on a preview online web site.
But I donot know how to display a zip/rar file as html format like it’s shown in windows OS system, could you share c# sample code?
zip display demo.png (39.3 KB)

with_folders.zip (61.1 KB)

Hello @davidxiao2008,
HTML format implies some web page probably with styles and a requirements for HTML tags to represent custom content. So I can not give a specific answer how to render archive content the same way as it is in Windows. However, in the next message I’ll provide you with code snippet demonstrating the principal idea of HTML representation.

The code below compose a HTML table that display some details of the archive entries. Run this code and review result.html composed. You can even open it with a web browser and see a draft table of the archive details.

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Aspose.Zip.License l = new();
l.SetLicense("Aspose.ZIP.NET.lic");
        
using FileStream output = File.Open("result.html", FileMode.Create);
using StreamWriter htmlWriter = new StreamWriter(output);
        
htmlWriter.WriteLine("<table>"); // Start the table
htmlWriter.WriteLine("<tr><th>Icon</th><th>Name</th><th>Size</th><th>Date</th></tr>"); // Row with headers

using (Archive a = new Archive("with_folders.zip"))
{
    foreach (ArchiveEntry entry in a.Entries)
    {
        htmlWriter.Write("<tr>"); // Start the row

        if (entry.IsDirectory)
            htmlWriter.Write("<td><img src='directory.png' /></td>"); // Render folder icon
        else if (entry.Name.EndsWith("txt", StringComparison.OrdinalIgnoreCase)) 
             htmlWriter.Write("<td><img src='text.png' /></td>"); // Render text document icon
        else if (entry.Name.EndsWith("tif", StringComparison.OrdinalIgnoreCase))
             htmlWriter.Write("<td><img src='picture.png' /></td>"); // Render image document icon
         // else if ... 
                
        htmlWriter.Write($"<td>{entry.Name}</td>"); // Render entry name
                
        if (entry.IsDirectory)
              htmlWriter.Write("<td></td>"); // No size for directory
        else
              htmlWriter.Write($"<td>{entry.UncompressedSize} bytes</td>"); // Render size of file
                
         htmlWriter.Write($"<td>{entry.ModificationTime.ToShortDateString()}</td>"); // Render modification date
                
         htmlWriter.WriteLine("</tr>"); // End the row
     }
}
        
htmlWriter.Write("</table>"); // Finish table

Got it.
Thanks for your share.