GdPicture.NET.14
GdPicture14 Namespace / GdPictureDocumentUtilities Class / GetDocumentFormat Method / GetDocumentFormat(Stream,String) 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.
The name of the original file. This parameter can help the format detection algorithm to distinguish format using the same signature pattern.
Example





In This Topic
GetDocumentFormat(Stream,String) Method
In This Topic
Determines the format of a required document from a previously instantiated Stream object with the help of the original file name.

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, _
   ByVal FileName As String _
) As DocumentFormat
[ComVisible(false)]
public static DocumentFormat GetDocumentFormat( 
   Stream Stream,
   string FileName
)
public function GetDocumentFormat( 
    Stream: Stream;
    FileName: String
): DocumentFormat; static; 
ComVisibleAttribute()
public static function GetDocumentFormat( 
   Stream : Stream,
   FileName : String
) : DocumentFormat;
[ComVisible(false)]
public: static DocumentFormat GetDocumentFormat( 
   Stream* Stream,
   string* FileName
) 
[ComVisible(false)]
public:
static DocumentFormat GetDocumentFormat( 
   Stream^ Stream,
   String^ FileName
) 

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.
FileName
The name of the original file. This parameter can help the format detection algorithm to distinguish format using the same signature pattern.

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 also the original file name.
Using fileStream As New FileStream("input.tif", FileMode.Open)
    Dim documentFormat As GdPicture14.DocumentFormat = GdPictureDocumentUtilities.GetDocumentFormat(fileStream, "input.tif")
    fileStream.Close()
End Using
using (FileStream fileStream = new FileStream("input.tif", FileMode.Open))
{
    GdPicture14.DocumentFormat documentFormat = GdPictureDocumentUtilities.GetDocumentFormat(fileStream, "input.tif");
    fileStream.Close();
}
See Also