GdPicture.NET.14
GdPicture14.WPF Namespace / GdViewer Class / DisplayFromStream Method / DisplayFromStream(Stream,String) Method
A System.IO.Stream object. This object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.
The file name of the document, that is stored in the Stream parameter, for example myfile.tif. The toolkit will automatically recognize the document format based on the file name to be able to display the required file.
Example





In This Topic
DisplayFromStream(Stream,String) Method
In This Topic
Loads a document from an instantiated Stream object according to what you have specified and subsequently displays it in the GdViewer control. The document previously displayed in the control will automatically close.

This method is useful for files, that have no header information in their internal structure, like text files or .svg files, as you can specify their file name to allow the toolkit with certainty to recognize the document format of the file for display.

All document formats currently supported by the toolkit are listed here.

The BeforeDocumentChange and the AfterDocumentChange events are raised just before and right after the document is displayed in the GdViewer control. Both events are only raised if the document has been successfully loaded.

Syntax
'Declaration
 
Public Overloads Function DisplayFromStream( _
   ByVal Stream As Stream, _
   ByVal FileName As String _
) As GdPictureStatus
public GdPictureStatus DisplayFromStream( 
   Stream Stream,
   string FileName
)
public function DisplayFromStream( 
    Stream: Stream;
    FileName: String
): GdPictureStatus; 
public function DisplayFromStream( 
   Stream : Stream,
   FileName : String
) : GdPictureStatus;
public: GdPictureStatus DisplayFromStream( 
   Stream* Stream,
   string* FileName
) 
public:
GdPictureStatus DisplayFromStream( 
   Stream^ Stream,
   String^ FileName
) 

Parameters

Stream
A System.IO.Stream object. This object must be properly initialized before it can be sent into this method and it must be disposed of by the user as well.
FileName
The file name of the document, that is stored in the Stream parameter, for example myfile.tif. The toolkit will automatically recognize the document format based on the file name to be able to display the required file.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks
Just to remind you that both the BeforeDocumentChange and the AfterDocumentChange events are raised using this method.
Example
How to display a simple textfile from a stream.
'We assume that the GdViewer1 control has been properly integrated.
Dim file As System.IO.Stream = New System.IO.FileStream("text.txt", System.IO.FileMode.Open)
If GdViewer1.DisplayFromStream(file, "text.txt") = GdPictureStatus.OK Then
    'Do your stuff here.
Else
    MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromStream")
End If
file.Dispose()
//We assume that the GdViewer1 control has been properly integrated.
System.IO.Stream file = new System.IO.FileStream("text.txt", System.IO.FileMode.Open);
if (GdViewer1.DisplayFromStream(file, "text.txt") == GdPictureStatus.OK)
{
    //Do your stuff here.
}
else
{
    MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromStream");
}
file.Dispose();
See Also