473,473 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

byte[] to string

Hi ALL.
Someone knows how can I convert a byte[] field to a string field?
The problem is, I'm uploading a xml file and I'm requesting the file using
Request.BinaryRead();

So, now I need to convert the result of Request.BinaryRead() method to a
string variable.

Thanks in advance.

FernandoLopes
Nov 16 '05 #1
4 3420
oj
You can take a look at ASCIIEncoding.GetString() method.

--
-oj
"Fernando Lopes" <fernandomattarlopes@[remove]msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi ALL.
Someone knows how can I convert a byte[] field to a string field?
The problem is, I'm uploading a xml file and I'm requesting the file using
Request.BinaryRead();

So, now I need to convert the result of Request.BinaryRead() method to a
string variable.

Thanks in advance.

FernandoLopes

Nov 16 '05 #2
Fernando Lopes <fernandomattarlopes@[remove]msn.com> wrote:
Someone knows how can I convert a byte[] field to a string field?


Use Encoding.GetString.

You need to know what encoding the binary data is in though.
See http://www.pobox.com/~skeet/csharp/unicode.html

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

Fernando

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Fernando Lopes <fernandomattarlopes@[remove]msn.com> wrote:
Someone knows how can I convert a byte[] field to a string field?


Use Encoding.GetString.

You need to know what encoding the binary data is in though.
See http://www.pobox.com/~skeet/csharp/unicode.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4
If you're going to be transporting your string over the web you should
probably convert your bytes to a Base64 string using
Convert.ToBase64String(byte []) and then get the bytes back on the other end
using Conver.FromBase64String(string).

HTH

DalePres

"Fernando Lopes" <fernandomattarlopes@[remove]msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi ALL.
Someone knows how can I convert a byte[] field to a string field?
The problem is, I'm uploading a xml file and I'm requesting the file using
Request.BinaryRead();

So, now I need to convert the result of Request.BinaryRead() method to a
string variable.

Thanks in advance.

FernandoLopes

Nov 16 '05 #5

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

Similar topics

3
by: Nick | last post by:
I have found a class that compresses and uncompresses data but need some help with how to use part of it below is the deflate method which compresses the string that I pass in, this works OK. At...
2
by: Jose Perez | last post by:
Dear All, I have the following problem. I am passing an encrypted value on the querystring from one aspx to another. Originally I was outputing characters such as "+, /,..." (which caused...
2
by: Bryan | last post by:
Apologies if this is a noob question, but I've been struggling with this for quite a while... I'm trying to convert a byte array (encrypted authorization code) into a *screen-printable* string...
8
by: moondaddy | last post by:
I need to convert a byte array to a string and pass it as a parameter in a URL and then convert it back to the original byte array. However, its getting scrambled in the conversion. In short,...
6
by: moondaddy | last post by:
I'm writing an app in vb.net 1.1 and need to convert a byte array into a string, and then from a string back to a byte array. for example Private mByte() as New Byte(4){11,22,33,44} Now how...
4
by: ThunderMusic | last post by:
Hi, I have to go from Byte() to String, do some processing then reconvert the String to byte() but using ascii format, not unicode. I currently use a stream to write the char()...
10
by: Danny | last post by:
I am working on a project where I will receive xml documents from clients machines as a byte array. They will use the web browser navigate method to post the data to my ASP.NET page. I then pick up...
5
by: jeremyje | last post by:
I'm writing some code that will convert a regular string to a byte for compression and then beable to convert that compressed string back into original form. Conceptually I have.... For...
6
by: =?Utf-8?B?TWljaGFlbA==?= | last post by:
Hi, I need to create a formatted byte array for SMPP, e.g.: 00 00 00 21 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 is the length of the entire...
10
by: ShadowLocke | last post by:
I'm looking for a better understanding of whats going on with the code i write. I have come across something that I thought I understood but its not working as expected. Its hard to explain so let me...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.