Get file info

GroupDocs.Comparison allows you to get the following file information:

  • FileType represents the document file type (PDF, Word document, Excel spreadsheet, PowerPoint presentation or image etc.).
  • PageCount represents count of document pages.
  • FileSize represents the document file size.
  • PagesInfo represents the page information.

The following code samples show how to get file information:

Get file info for the file from local disk

using System;
using GroupDocs.Comparison;
using GroupDocs.Comparison.Interfaces;
// ...

using (Comparer comparer = new Comparer("source.docx"))
{
    IDocumentInfo info = comparer.Source.GetDocumentInfo();
    for (int i = 0; i < info.PageCount; i++)
    {
        Console.WriteLine("\n" +
            "Page number: {5}\n" +
            "File type: {0}\n" +
            "Number of pages: {1}\n" +
            "Document size: {2} bytes\n" +
            "Width: {3}\n" +
            "Height: {4} ",
            info.FileType, 
            info.PageCount, 
            info.Size, 
            info.PagesInfo[i].Width, 
            info.PagesInfo[i].Height, i + 1
        );
    }
}

The result is as follows:

Get file info for the file from stream

using System;
using GroupDocs.Comparison;
using GroupDocs.Comparison.Interfaces;
using System.IO;
// ...

using (Comparer comparer = new Comparer(File.OpenRead("source.docx")))
{
    IDocumentInfo info = comparer.Source.GetDocumentInfo();
    for (int i = 0; i < info.PageCount; i++)
    {
        Console.WriteLine("\n" +
            "Page number: {5}\n" +
            "File type: {0}\n" +
            "Number of pages: {1}\n" +
            "Document size: {2} bytes\n" +
            "Width: {3}\n" +
            "Height: {4} ",
            info.FileType, 
            info.PageCount, 
            info.Size, 
            info.PagesInfo[i].Width, 
            info.PagesInfo[i].Height, i + 1
        );
    }
}