Click or drag to resize

DocumentIdentifierIdentify(Stream, String) Method

Identifies a document's file format type using internal binary signatures.

Namespace: OpenDiscoverSDK
Assembly: OpenDiscoverSDK (in OpenDiscoverSDK.dll) Version: 2025.4.4.0 (2025.4.4)
Syntax
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

IdResult
IdResult 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);
}
See Also