Class FileFormatInfo

FileFormatInfo class

Contains data returned by FileFormatUtil file format detection methods.

public class FileFormatInfo

Constructors

NameDescription
FileFormatInfo()The default constructor.

Properties

NameDescription
FileFormatType { get; }Gets the detected file format.
IsEncrypted { get; }Returns true if the document is encrypted and requires a password to open.
IsProtectedByRMS { get; }Gets whether the file is protected by Microsoft Rights Management Server.
LoadFormat { get; }Gets the detected load format.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using System;

    public class FileFormatInfoDemo
    {
        public static void FileFormatInfoExample()
        {
            // Load a sample file to detect its format
            string filePath = "sample.xlsx";
            FileFormatInfo fileInfo = FileFormatUtil.DetectFileFormat(filePath);

            // Display file format information
            Console.WriteLine("File Format Information:");
            Console.WriteLine($"Is Protected By RMS: {fileInfo.IsProtectedByRMS}");
            Console.WriteLine($"Is Encrypted: {fileInfo.IsEncrypted}");
            Console.WriteLine($"File Format Type: {fileInfo.FileFormatType}");
            Console.WriteLine($"Load Format: {fileInfo.LoadFormat}");

            // Save the information to a text file
            string outputFilePath = "FileFormatInfo.txt";
            using (System.IO.StreamWriter writer = new System.IO.StreamWriter(outputFilePath))
            {
                writer.WriteLine("File Format Information:");
                writer.WriteLine($"Is Protected By RMS: {fileInfo.IsProtectedByRMS}");
                writer.WriteLine($"Is Encrypted: {fileInfo.IsEncrypted}");
                writer.WriteLine($"File Format Type: {fileInfo.FileFormatType}");
                writer.WriteLine($"Load Format: {fileInfo.LoadFormat}");
            }

            Console.WriteLine($"File format information saved to {outputFilePath}");
        }
    }
}

See Also