Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Stream to String
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Stream to String
Divers
Thread ID:
01091728
Message ID:
01091728
Vues:
61
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.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform