DecodeFile Method

Description

Reads barcode from a local file specified by its full path.

Syntax

public BarcodeResult[] DecodeFile(string strFileName);

Parameters

strFileName
The path of the file.

Return Value

All barcodes have been read. If no barcodes are read, null is returned.

Remarks

The file to read needs to be an image in the formats BMP, JPG, PNG, TIFF or PDF.

Example

ReaderOptions option = new ReaderOptions();
option.BarcodeFormats = (
    BarcodeFormat.OneD | 
    BarcodeFormat.QR_CODE | 
    BarcodeFormat.PDF417 | 
    BarcodeFormat.DATAMATRIX
);
option.MaxBarcodesToReadPerPage = 100;
BarcodeReader reader = new BarcodeReader();
reader.ReaderOptions = option;
try
{
    BarcodeResult[] results = reader.DecodeFile("C:\\test.bmp");
    for(int i = 0; i < results.Length; ++i)
    {
        BarcodeResult barcode = results[i];
        Console.WriteLine("{0}: {1}", i, barcode.BarcodeText);
    }
}
catch(BarcodeReaderException exp)
{
    Console.WriteLine("Error: {0}, {1}", exp.Code.ToString(), exp.Message);
}

See Also

.NET > Classes > BarcodeReader > DecodeFileRect
.NET > Classes > ReaderOptions > BarcodeFormats
.NET > Classes > ReaderOptions > MaxBarcodesToReadPerPage
.NET > Classes > BarcodeReaderException
.NET > Enumeration > BarcodeFormat
.NET > Enumeration > ErrorCode