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