---
title: "Classify documents in C# .NET | Nutrient .NET SDK"
canonical_url: "https://www.nutrient.io/guides/dotnet/ocr/classify-documents/"
md_url: "https://www.nutrient.io/guides/dotnet/ocr/classify-documents.md"
last_updated: "2026-05-21T17:12:02.207Z"
description: "Learn how to classify documents programmatically in C# .NET using Nutrient .NET SDK. Implement intelligent document categorization in your applications."
---

# Classify documents in C# .NET

This guide explains how to recognize barcodes in a collection of documents and classify them accordingly. For example, this feature enables you to sort documents based on the type and value of their barcodes.

To classify documents based on the type and value of their barcodes, follow the steps outlined below. This procedure assumes that the source documents are all image files. The documents are classified based on the first scanned 1D barcode.

1. Create a `GdPictureImaging` object.

2. Define the source and the output folders. The source folder is where the original documents are. The output folder is where the documents are saved with a file name that includes information about the type and value of the barcode.

3. Loop through the files in the source folder.

4. Scan the 1D barcodes in each image using the `Barcode1DReaderDoScan` method.

5. Save the document in the output folder with a file name that includes information about the type and value of the first 1D barcode in the document.

6. Release unnecessary resources.

The example below recognizes the 1D barcodes in each document within the source folder and saves the document in the output folder with a file name that includes information about the type and value of the barcode:

### C#

```csharp

using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Define the source and output folders.
string sourceFolder = @"C:\temp\source\";
string outputFolder = @"C:\temp\output\";
string[] allFiles = Directory.GetFiles(sourceFolder);
int imageID = 0;
// Loop through the files in the source folder.
foreach (string sourceFilePath in allFiles)
{
    imageID = gdpictureImaging.CreateGdPictureImageFromFile(sourceFilePath);
    // Scan the barcode.
    gdpictureImaging.Barcode1DReaderDoScan(imageID);
    // Save the document in the output folder with a file name that includes information about the type and value of the first barcode in the document.
    string outputFilepath = $"{outputFolder}{gdpictureImaging.Barcode1DReaderGetBarcodeType(1)}-{gdpictureImaging.Barcode1DReaderGetBarcodeValue(1)}.png";
    gdpictureImaging.SaveAsPNG(imageID, outputFilepath);
    // Release unnecessary resources.
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}

```

### VB.NET

```vb

Using gdpictureImaging As GdPictureImaging = New GdPictureImaging()
    ' Define the source and output folders.
    Dim sourceFolder = "C:\temp\source\"
    Dim outputFolder = "C:\temp\output\"
    Dim allFiles = Directory.GetFiles(sourceFolder)
    Dim imageID = 0
    ' Loop through the files in the source folder.
    For Each sourceFilePath In allFiles
        imageID = gdpictureImaging.CreateGdPictureImageFromFile(sourceFilePath)
        ' Scan the barcode.
        gdpictureImaging.Barcode1DReaderDoScan(imageID)
        ' Save the document in the output folder with a file name that includes information about the type and value of the first barcode in the document.
        Dim outputFilepath = $"{outputFolder}{gdpictureImaging.Barcode1DReaderGetBarcodeType(1)}-{gdpictureImaging.Barcode1DReaderGetBarcodeValue(1)}.png"
        gdpictureImaging.SaveAsPNG(imageID, outputFilepath)
        ' Release unnecessary resources.
        gdpictureImaging.ReleaseGdPictureImage(imageID)
    Next
End Using

```

#### Used methods and properties

- [`Barcode1DReaderDoScan`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~Barcode1DReaderDoScan.html)

- [`Barcode1DReaderGetBarcodeValue`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~Barcode1DReaderGetBarcodeValue.html)

- [`CreateGdPictureImageFromFile`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~CreateGdPictureImageFromFile.html)

- [`SaveAsPNG`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~SaveAsPNG.html)

- [`ReleaseGdPictureImage`](/api/gdpicture/GdPicture.NET.14.API~GdPicture14.GdPictureImaging~ReleaseGdPictureImage.html)

#### Related topics

- [Load a file](/guides/dotnet/load-a-file.md)

- [Save a file](/guides/dotnet/save-a-file.md)

---

## Related pages

- [C# OCR bank checks to text](/guides/dotnet/ocr/bank-checks.md)
- [C# OCR forms to text](/guides/dotnet/ocr/forms.md)
- [C# OCR ID cards to text](/guides/dotnet/ocr/id-cards.md)
- [C# OCR driver’s licenses to text](/guides/dotnet/ocr/drivers-licenses.md)
- [C# .NET OCR library](/guides/dotnet/ocr.md)
- [C# OCR invoices to text](/guides/dotnet/ocr/invoices.md)
- [C# OCR passports to text](/guides/dotnet/ocr/passports.md)
- [C# OCR MRZ to text](/guides/dotnet/ocr/mrz.md)
- [C# OCR receipts to text](/guides/dotnet/ocr/receipts.md)
- [Supported languages: 100+ OCR language dictionaries](/guides/dotnet/ocr/language-support.md)
- [C# OCR visas to text](/guides/dotnet/ocr/visas.md)
- [Zonal OCR in C# .NET](/guides/dotnet/ocr/zonal.md)
- [Create custom OCR parameters in C#](/guides/dotnet/ocr/parameters.md)

