By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,260 Members | 1,329 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,260 IT Pros & Developers. It's quick & easy.

Dumb Question

P: n/a
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
Feb 28 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a


"Robert Dufour" <bd*****@sgiims.comwrote in message
news:Oi**************@TK2MSFTNGP03.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.Close()
End Try

Dim memStream As MemoryStream = New MemoryStream(bytes)

HTH,
Mythran
Mar 1 '07 #2

P: n/a
Thanks
"Mythran" <ki********@hotmail.comwrote in message
news:E3**********************************@microsof t.com...
>

"Robert Dufour" <bd*****@sgiims.comwrote in message
news:Oi**************@TK2MSFTNGP03.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.Close()
End Try

Dim memStream As MemoryStream = New MemoryStream(bytes)

HTH,
Mythran


Mar 1 '07 #3

P: n/a
Mythran wrote:
>

"Robert Dufour" <bd*****@sgiims.comwrote in message
news:Oi**************@TK2MSFTNGP03.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.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.

--
Göran Andersson
_____
http://www.guffa.com
Mar 1 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.