Convert byte array to string

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

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?
 
ASCIIEncoding.GetString(Byte())

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?
 
Dan said:
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?

That doesn't make sense. If it's a byte array, the data is binary already --
just write the bytes to your network stream. Or did you mean it the other
way around?

Cheers,
 
Dan said:
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?

See http://www.pobox.com/~skeet/csharp/unicode.html

Joerg's post is spot-on - but if you *really* need to convert the byte
array into text, I'd suggest using Base64 encoding. See
Convert.ToBase64String and Convert.FromBase64String.
 
Back
Top