class Foo { static bool Bar(Stream^ stream); }; class FooWrapper { bool Bar(LPCWSTR szUnicodeString) { return Foo::Bar(??); } };
MemoryStream will take a byte[] but I’d like to do this without copying the data if possible.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can avoid the copy if you use an
UnmanagedMemoryStream()instead (class exists in .NET FCL 2.0 and later). LikeMemoryStream, it is a subclass ofIO.Stream, and has all the usual stream operations.Microsoft’s description of the class is:
which pretty much tells you what you need to know. Note that
UnmanagedMemoryStream()is not CLS-compliant.