Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Getting stream into string? better way?

  Asked By: Aditi    Date: Apr 25    Category: Asp.net    Views: 652
  

I have a memory stream with an XML document in it, created using the
XmlTextWriter. I wanted to put the memory stream into a string, so
that I could perform some Regular Expression work on the string.

Everything works great, except that this,

sStr = Encoding.UTF8.GetString(objStream.ToArray())

returns a string with a "garbage" character at the beginning that I
have to first strip before using the result, with this,

sStr = sStr.Remove(0, 1)

I've read that when using the "Encoding" class, that there can
be "special encoding characters" purposely present at the beginning
of the string. This is just annoying, and presents the overhead of a
string copy in the extra step! Is there a better way to get a stream
into a string?

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Getting stream into string? better way? Or get search suggestion and latest updates.




Tagged: