Get file info

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

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
        );
    }
}

See also