473,698 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert byte array to stream

Can anyone tell me how to convert a byte array to a stream.?
Thanks
Andrew

Nov 16 '05 #1
5 134754
"Andrew Inwards" <an****@nospam. com> wrote in news:#wI$S4RVEH A.2544
@TK2MSFTNGP10.p hx.gbl:
Can anyone tell me how to convert a byte array to a stream.?
Thanks
Andrew


Create a memory stream, write the contents of the array to it.

--
Lasse Vågsæther Karlsen
la***@vkarlsen. no
PGP KeyID: 0x0270466B
Nov 16 '05 #2
Hello Andrew,

You can create a MemoryStream instance from that array.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Andrew Inwards" <an****@nospam. com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Can anyone tell me how to convert a byte array to a stream.?
Thanks
Andrew


Nov 16 '05 #3
Lasse Vågsæther Karlsen <la***@vkarlsen .no> wrote:
Can anyone tell me how to convert a byte array to a stream.?


Create a memory stream, write the contents of the array to it.


It's easier than that:

Stream s = new MemoryStream(by teArray);

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
Thanks for the quick response.

"Lasse Vågsæther Karlsen" <la***@vkarlsen .no> wrote in message
news:Xn******** *************** ******@207.46.2 48.16...
"Andrew Inwards" <an****@nospam. com> wrote in news:#wI$S4RVEH A.2544
@TK2MSFTNGP10.p hx.gbl:
Can anyone tell me how to convert a byte array to a stream.?
Thanks
Andrew


Create a memory stream, write the contents of the array to it.

--
Lasse Vågsæther Karlsen
la***@vkarlsen. no
PGP KeyID: 0x0270466B

Nov 16 '05 #5
Jon Skeet [C# MVP] <sk***@pobox.co m> wrote in
news:MP******** *************** *@msnews.micros oft.com:
Lasse Vågsæther Karlsen <la***@vkarlsen .no> wrote:
> Can anyone tell me how to convert a byte array to a stream.?


Create a memory stream, write the contents of the array to it.


It's easier than that:

Stream s = new MemoryStream(by teArray);


Thanks for the update, didn't know about that one :)

--
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/
PGP KeyID: 0x0270466B
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
15318
by: Gator | last post by:
Hi All, Basically my situation is this, I have a server implemented in C++, unmanaged code, using proprietery protocol over TCP/IP to communicate with the cilent(c++ also). Now, I am implementing the another client in C#. Server side can not be changed :( So, I am using tcp/ip sockets. In the end I get byte on the client side, which originally was some C++ class object, converted to byte array.
4
33130
by: Dan | last post by:
I need to convert a byte array to a string in order to upload a binary file with an httpWebRequest. What's the most efficient way to do such a conversion?
2
9605
by: Dave | last post by:
Hi, I'm trying to convert a byte array to string --This works... System.BitConverter.ToString(bytes) "EB-55-79-20-18-B2-76-4D-85-0A-93-6B-97-33-31-B8" --This doesn't, but returns "System.Byte". How do I do this with System.Convert.ToString()???
5
4194
by: Terry Olsen | last post by:
Looking for info on how to convert a byte array to a string, and string to byte array. Thanks.
14
29718
by: Charles Law | last post by:
I thought this had come up before, but I now cannot find it. I have a byte array, such as Dim a() As Byte = {1, 2, 3, 4} I want to convert this to an Int32 = 01020304 (hex). If I use BitConverter, I get 04030201.
0
2416
by: Sergei Shelukhin | last post by:
Hi. I receive a byte array that contains utf-16 string (with a lot of \0 characters :)) from a legacy system that holds some data that is changed elsewhere. How do I convert it to an actual utf-16 string for my app's purposes? I am using php 5.
18
43078
by: MrVS | last post by:
Hi, I have a C++ CLR class method that takes System::Byte *b as parameter argument. I want the CSharp caller pass a byte * to this function. But in the CSharp prorgram, I only managed to create a byte array (byte). Can anyone tell me how to convert byte array to byte pointer in CSharp? Please show me an simple example about how to do it. Thank you for your help
0
9169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.