all groups > dotnet interop > november 2007 >
You're in the

dotnet interop

group:

BYTE* buffer to managed stream?


BYTE* buffer to managed stream? Scott McFadden
11/30/2007 2:55:52 PM
dotnet interop:
In managed c++, what is the most efficient way to copy the contents of a
native buffer (BYTE*) to a managed stream?

thanks

scott

Re: BYTE* buffer to managed stream? Scott McFadden
11/30/2007 4:57:35 PM
Thanks, it appears that the UnmanagedMemoryStream can't be chained to
another stream. Would be nice if you could write a block of native memory
to the UnmanagedStream and have it write to the chained / underlying stream.


[quoted text, click to view]

Re: BYTE* buffer to managed stream? Mattias Sjögren
11/30/2007 11:19:11 PM
[quoted text, click to view]

As of .NET 2.0 you can use the System.IO.UnmanagedMemoryStream. It
wraps the native buffer directly so it doesn't require any copying.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
AddThis Social Bookmark Button