Document IdentifierIdentify(Stream, String) Method
Identifies a document's file format type using internal binary signatures.
Definition
Namespace: OpenDiscoverSDK
Assembly: OpenDiscoverSDK (in OpenDiscoverSDK.dll) Version: 2026.2.6.0 (2026.02.06)
IdResult object containing information on the identified file format.
Assembly: OpenDiscoverSDK (in OpenDiscoverSDK.dll) Version: 2026.2.6.0 (2026.02.06)
C#
public static IdResult Identify(
Stream documentStream,
string filePath
)Parameters
- documentStream Stream
- Open read-only stream to file. The stream's Position is automatically set back to 0 upon exit.
- filePath String
- The full document file path or file name with extension SHOULD always be passed in as an argument. The file extension is used to help judge quality (confidence) of identification. However, null or empty strings are valid but NOT recommended.
Return Value
IdResultIdResult object containing information on the identified file format.
Example
Example file identification unit test that illustrates some of the properties on the returned IdResult object:
C#
using (var stream = File.OpenRead(@"C:\WordProcessing\Word2003.doc"))
{
var idResult = DocumentIdentifier.Identify(stream, "Word2003.doc");
Assert.IsTrue(idResult.ID == Id.Word2003);
Assert.IsTrue(idResult.Classification == IdClassification.WordProcessing); // Classification of format
Assert.IsTrue(idResult.MatchType == IdMatchType.SignatureAndExtension); // Quality of identication
Assert.IsTrue(idResult.IsEncrypted == false);
Assert.IsTrue(idResult.MediaType == "application/msword");
Assert.IsTrue(idResult.Description != null);
Assert.IsTrue(idResult.PrimaryExtension != null);
Assert.IsTrue(idResult.Extensions != null);
}