GdPicture.NET.14.API
GdPicture14 Namespace / GdPictureDocumentUtilities Class / GetDocumentFormat Method / GetDocumentFormat(Stream) Method
A System.IO.Stream object. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use. At the same, the provided stream object must support seeking, otherwise the method will fail.
Example





In This Topic
GetDocumentFormat(Stream) Method
In This Topic
Determines the format of a required document from a previously instantiated Stream object.

The method firstly favors popular formats by their extension. Secondly, it validates the file content to find the proper document format.

Syntax
'Declaration
 
<ComVisibleAttribute(False)>
Public Overloads Shared Function GetDocumentFormat( _
   ByVal Stream As Stream _
) As DocumentFormat
[ComVisible(false)]
public static DocumentFormat GetDocumentFormat( 
   Stream Stream
)
public function GetDocumentFormat( 
    Stream: Stream
): DocumentFormat; static; 
ComVisibleAttribute()
public static function GetDocumentFormat( 
   Stream : Stream
) : DocumentFormat;
[ComVisible(false)]
public: static DocumentFormat GetDocumentFormat( 
   Stream* Stream
) 
[ComVisible(false)]
public:
static DocumentFormat GetDocumentFormat( 
   Stream^ Stream
) 

Parameters

Stream
A System.IO.Stream object. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use. At the same, the provided stream object must support seeking, otherwise the method will fail.

Return Value

A member of the DocumentFormat enumeration. The format of the specified document.
Remarks
Please note that the specified stream should remain open during running this method and it needs to be closed by the user as well. At the same, the provided stream must support seeking, otherwise the method returns the GdPicture14.DocumentFormat.DocumentFormatUNKNOWN.
Example
How to properly retrieve the format of an image file stored within a stream.
Using fileStream As New FileStream("input.tif", FileMode.Open)
    Dim documentFormat As GdPicture14.DocumentFormat = GdPictureDocumentUtilities.GetDocumentFormat(fileStream)
    fileStream.Close()
End Using
using (FileStream fileStream = new FileStream("input.tif", FileMode.Open))
{
    GdPicture14.DocumentFormat documentFormat = GdPictureDocumentUtilities.GetDocumentFormat(fileStream);
    fileStream.Close();
}
See Also