Compartir a través de


JournalReader.ReadFromStream Method

Takes a stream to a Journal Note file and returns an XML stream representing the contents of the document.

Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)

Syntax

'Declaration
Public Shared Function ReadFromStream ( _
    inputStream As Stream _
) As Stream
'Usage
Dim inputStream As Stream
Dim returnValue As Stream

returnValue = JournalReader.ReadFromStream(inputStream)
public static Stream ReadFromStream (
    Stream inputStream
)
public:
static Stream^ ReadFromStream (
    Stream^ inputStream
)
public static Stream ReadFromStream (
    Stream inputStream
)
public static function ReadFromStream (
    inputStream : Stream
) : Stream
Not applicable.

Parameters

  • inputStream

Return Value

Returns a Stream object containing the XML created by reading the Journal Note file.

Remarks

Stream objects are used to avoid direct access to the file system and to allow choice in which XML parsing method to use.

Example

The following C# example of a handler for a button's Click event creates an instance of the JournalReader class and uses it to read an existing Journal file.

Note

The DisplayXml method called from this example is not shown. The specific implementation of such a method is dependent on your application's needs.

private void btnLoad_Click(object sender, System.EventArgs e)
{
  Stream jntStream;
  Stream xmlStream;
  Microsoft.Ink.JournalReader jntReader = new Microsoft.Ink.JournalReader();
  OpenFileDialog openFileDialog1 = new OpenFileDialog();

  // Get the filename from the user by using a File Open dialog
  openFileDialog1.InitialDirectory = "c:\\";
  openFileDialog1.Filter = 
    "Journal files (*.jnt)|*.jnt|All files (*.*)|*.*";
  openFileDialog1.FilterIndex = 1;
  openFileDialog1.RestoreDirectory = true;

  if (openFileDialog1.ShowDialog() == DialogResult.OK)
  {
    try
    {
      if ((jntStream =   openFileDialog1.OpenFile()) != null)
      {
        // Read in the Journal file
        xmlStream = jntReader.ReadFromStream(jntStream);

        // Display results
        DisplayXml(xmlStream);
      }
    }
    catch (System.Exception ex)
    {
        Debug.WriteLine(ex.Message);
    }
    finally
    {
        // Clean up
        xmlStream.Close();
        jntStream.Close();
    }
  }
}

The following Microsoft Visual Basic® .NET example of a handler for a button's Click event creates an instance of the JournalReader class and uses it to read an existing Journal file.

Note

The DisplayXml method called from this example is not shown. The specific implementation of such a method is dependent on your application's needs.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
  Dim jntStream As Stream
  Dim xmlStream As Stream
  Dim jntReader As New Microsoft.Ink.JournalReader()
  Dim openFileDialog1 As New OpenFileDialog()

  ' Get the filename from the user by using a File Open dialog
  openFileDialog1.InitialDirectory = "C:\"
  openFileDialog1.Filter = _
    "Journal files (*.jnt)|*.jnt|All files (*.*)|*.*"
  openFileDialog1.FilterIndex = 1
  openFileDialog1.RestoreDirectory = True

  If openFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
    Try
      jntStream = openFileDialog1.OpenFile()

      ' Read in the Journal file
      xmlStream = jntReader.ReadFromStream(jntStream)

      ' Show the results
      DisplayXml(xmlStream)
    Catch ex As Exception
      Debug.WriteLine(ex.Message)
    Finally
      ' Clean up
      xmlStream.Close()
      jntStream.Close()
    End Try
  End If
End Sub

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

JournalReader Class
JournalReader Members
Microsoft.Ink Namespace

Other Resources

Journal Reader Schema Reference