Dumb Question

  • Thread starter Thread starter Robert Dufour
  • Start date Start date
R

Robert Dufour

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
 
Robert Dufour said:
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.Close()
End Try

Dim memStream As MemoryStream = New MemoryStream(bytes)

HTH,
Mythran
 
Thanks
Mythran said:
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.Close()
End Try

Dim memStream As MemoryStream = New MemoryStream(bytes)

HTH,
Mythran
 
Mythran said:
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.Close()
End Try

Dim memStream As MemoryStream = New MemoryStream(bytes)

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.ReadAllBytes
to read the entire file.
 
Back
Top