---
title: "Image template matching in C# .NET | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/document-recognition/classify-document/"
md_url: "https://www.nutrient.io/guides/dotnet/document-recognition/classify-document.md"
last_updated: "2026-05-15T19:10:04.984Z"
description: "Learn how to match and identify image templates in C# using Nutrient .NET SDK. Implement document recognition and classification features in your applications."
---

# Match and identify image templates in C#

The code below categorizes a document in the following ways:

- It creates two templates.

- It identifies the template whose content most closely matches the content of the document.

- It renames the document file using the name of the template.

- It deletes the templates.

```csharp

// C#

// We assume GdPicture has been correctly installed and unlocked.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    // Create template A.
    int templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateA.tif");
    gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateA");

    // Create template B.
    templateID = gdpictureImaging.ADRCreateTemplateFromFile(@"templateB.tif");
    gdpictureImaging.ADRSetTemplateTag(templateID, "TemplateB");

    // Identify the template that has the best similar content and change the file name accordingly.
    templateID = gdpictureImaging.ADRGetCloserTemplateForFile("image.tif");
    string templateName = gdpictureImaging.ADRGetTemplateTag(templateID);
    File.Move("image.tif", templateName + "_image.tif");

    // Deletes all document identifier templates.
    int templateCount = gdpictureImaging.ADRGetTemplateCount();
    for (int i = 1; i <= templateCount; i++)
    {
        templateID = gdpictureImaging.ADRGetTemplateID(1);
        gdpictureImaging.ADRDeleteTemplate(templateID);
    }
}

```

---

## Related pages

- [Automatic document recognition using C#](/guides/dotnet/document-recognition.md)

