Dumb Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Robert Dufour

    Dumb Question

    How do you read all the data from an enhanced metafile and put it in a
    memory stream?

    Myfile.emf is part of my solution but I can't get the trick to read all of
    it in a stream.

    Thanks for any help,

    Bob


  • Mythran

    #2
    Re: Dumb Question



    "Robert Dufour" <bdufour@sgiims .comwrote in message
    news:OiUqfx4WHH A.5092@TK2MSFTN GP03.phx.gbl...
    How do you read all the data from an enhanced metafile and put it in a
    memory stream?
    >
    Myfile.emf is part of my solution but I can't get the trick to read all of
    it in a stream.
    >
    Thanks for any help,
    >
    Bob
    >
    >
    Code off top of my head:

    Dim bytes As Byte()
    Dim fileStream As FileStream = File.OpenRead(" C:\myfile.emf")

    Try
    Dim len As Integer = CInt(fileStream .Length)
    fileStream.Read (bytes, 0, len)
    Finally
    fileStream.Clos e()
    End Try

    Dim memStream As MemoryStream = New MemoryStream(by tes)

    HTH,
    Mythran


    Comment

    • Robert Dufour

      #3
      Re: Dumb Question

      Thanks
      "Mythran" <kip_potter@hot mail.comwrote in message
      news:E386AD58-110D-4C27-873D-6F3B8495D7A9@mi crosoft.com...
      >
      >
      "Robert Dufour" <bdufour@sgiims .comwrote in message
      news:OiUqfx4WHH A.5092@TK2MSFTN GP03.phx.gbl...
      >How do you read all the data from an enhanced metafile and put it in a
      >memory stream?
      >>
      >Myfile.emf is part of my solution but I can't get the trick to read all
      >of it in a stream.
      >>
      >Thanks for any help,
      >>
      >Bob
      >>
      >>
      >
      Code off top of my head:
      >
      Dim bytes As Byte()
      Dim fileStream As FileStream = File.OpenRead(" C:\myfile.emf")
      >
      Try
      Dim len As Integer = CInt(fileStream .Length)
      fileStream.Read (bytes, 0, len)
      Finally
      fileStream.Clos e()
      End Try
      >
      Dim memStream As MemoryStream = New MemoryStream(by tes)
      >
      HTH,
      Mythran
      >
      >

      Comment

      • =?windows-1252?Q?G=F6ran_Andersson?=

        #4
        Re: Dumb Question

        Mythran wrote:
        >
        >
        "Robert Dufour" <bdufour@sgiims .comwrote in message
        news:OiUqfx4WHH A.5092@TK2MSFTN GP03.phx.gbl...
        >How do you read all the data from an enhanced metafile and put it in a
        >memory stream?
        >>
        >Myfile.emf is part of my solution but I can't get the trick to read
        >all of it in a stream.
        >>
        >Thanks for any help,
        >>
        >Bob
        >>
        >>
        >
        Code off top of my head:
        >
        Dim bytes As Byte()
        Dim fileStream As FileStream = File.OpenRead(" C:\myfile.emf")
        >
        Try
        Dim len As Integer = CInt(fileStream .Length)
        fileStream.Read (bytes, 0, len)
        Finally
        fileStream.Clos e()
        End Try
        >
        Dim memStream As MemoryStream = New MemoryStream(by tes)
        >
        HTH,
        Mythran
        >
        >
        You ignore the return value of the call to the Read method. That means
        that the entire file might not have been read, but you will silently
        ignore that.

        Get the return value of the call to see how much of the array that has
        been filled, and loop until you have gotten the entire file.

        If you are using framework 2.0+, you can instead use File.ReadAllByt es
        to read the entire file.

        --
        Göran Andersson
        _____
        Göran Anderssons privata hemsida.

        Comment

        Working...