DocumentIdentifierIdentify(Stream, String) Method |
Identifies a document's file format type using internal binary signatures.
Namespace: OpenDiscoverSDKAssembly: OpenDiscoverSDK (in OpenDiscoverSDK.dll) Version: 2025.4.4.0 (2025.4.4)
Syntaxpublic 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:
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);
Assert.IsTrue(idResult.MatchType == IdMatchType.SignatureAndExtension);
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