By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,245 Members | 1,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,245 IT Pros & Developers. It's quick & easy.

How to convert a Stream to a String

P: n/a
ad
I have a Steam, it read from a text file.
How can I convert this Stream to a String?
May 16 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
What kind of stream? You should be able to use a StreamReader to get
the contents of the stream.

May 16 '06 #2

P: n/a
ad wrote:
I have a Steam, it read from a text file.
How can I convert this Stream to a String?


Is StreamReader.ReadToEnd() what you are looking for?
May 16 '06 #3

P: n/a
ad wrote:
I have a Steam, it read from a text file.
How can I convert this Stream to a String?


See the following:

How to: Read Text from a File
http://msdn2.microsoft.com/en-us/library/db5x7c0d.aspx
--
Tom Porterfield
May 16 '06 #4

P: n/a
"ad" <fl****@wfes.tcc.edu.tw> wrote:
I have a Steam, it read from a text file.
How can I convert this Stream to a String?


The easiest way is skip the stream and just do File.ReadAllText().

Alternatively, if you must use the stream, then do:

---8<---
new StreamReader(stream).ReadToEnd()
--->8---

-- Barry
May 16 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.