File Content Extraction 26.3
Filter SDK .NET Programming Guide

# Process Subfiles

To filter all files in a container file, you can open the container as a Document object, then open its subfiles as Document objects. After you open a subfile as a Document, you can call its methods to filter the data.

You can iterate over subfile objects by calling the `subfiles` method on a document. Each element returned by the iterator contains information about the subfile, and a method to open it as a document.

In the following example, we open each subfile as a document, and filter some text from it.

Copy

    using (Subfiles subfiles = doc.Subfiles())
    {
        foreach (Subfile subfile in subfiles) using (subfile)
        {
            var (child, info) = subfile.Open();
            if (child != null)
            {
                using (child)
                {
                    child.Filter(outFileStream);
                }
            }
        }
    }

## Extract Subfiles

In some cases, you might need to access the subfiles directly, for example to archive the subfiles or process them using a different tool. In this case, you can open the container as a Document object, then open its subfiles as Document objects. After you open a subfile as a Document, you can call its methods to filter the data.

You can iterate over subfile information by calling the `Subfiles` method on a document object. Each element returned by the iterator contains information about the subfile, and a method to let you extract it:

Copy

    foreach (Subfile file in myDoc.Subfiles()) using (file)
    {
        Console.WriteLine($"Subfile {file.Index()}, size: {file.Size()}");
        if (file.GetSubfileType() != SubfileType.Folder)
        {
            string outputPath = GenerateOutputPath(file);
            file.Extract(outputPath);
        }
    }

In this example, `GenerateOutputPath()` is a function that returns the path you want to use for the extracted subfile. If the name of the subfile does not matter (for example, the subfile will being passed into File Content Extraction for further processing) you could use a unique identifier like a GUID. If you instead choose to base the filename on `Subfile.RawName()` - the path the container file provides - you should ensure you protect against directory traversal attacks (where the name of the subfile contains a relative or absolute path).

NOTE: Some options change the order in which subfiles are retrieved, such as enabling the root node. However, for each combination of options, the subfile order is consistent across multiple runs.

Copyright 1997-2026 Open Text
Version 26.3 | Last updated July 2026

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: File Content Extraction 26.3

Topic Title: Process Subfiles