Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stream to String
Message
General information
Forum:
ASP.NET
Category:
Other
Title:
Stream to String
Miscellaneous
Thread ID:
01091728
Message ID:
01091728
Views:
62
I want to convert an embedded resourse stream to a string. The following code does what I want it to:
byte[] ba;
using (System.IO.Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(sResouce))
{
  ba = new byte[s.Length];
  s.Read(ba, 0, ba.Length);
}

string myString = System.Text.ASCIIEncoding.ASCII.GetString(ba);
Is there a better way to do this? It just seems like a lot of work to first convert the Stream to a byte array and then convert it to a string.

Any other thoughts?

Thanks,
Einar
Semper ubi sub ubi.
Next
Reply
Map
View

Click here to load this message in the networking platform