Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in .NET only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Member List
Calendar
Today's Posts
Home
Forum
Topic
.NET
System.IO.Stream to string
System.IO.Stream to string
Collapse
This topic is closed.
X
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
Paul
#1
System.IO.Stream to string
Sep 30 '05, 05:05 AM
How do I convert a System.IO.Strea m to a string variable.
Regards Paul
Jon Skeet [C# MVP]
#2
Sep 30 '05, 05:25 AM
Re: System.IO.Strea m to string
Paul <Paul@discussio ns.microsoft.co m> wrote:[color=blue]
> How do I convert a System.IO.Strea m to a string variable.[/color]
Do you mean you want to read the contents of a stream, decoding it into
a string, and storing the result in a variable? If so:
using (StreamReader reader = new StreamReader(st ream))
{
string contents = reader.ReadToEn d();
}
Note that the above assumes an encoding of UTF-8. If you want a
different encoding, specify it in the StreamReader constructor.
--
Jon Skeet - <skeet@pobox.co m>
http://www.pobox.com/~skeet
Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Comment
Post
Cancel
Previous
template
Next
Working...
OK
OK
Cancel
👍
👎
☕
Comment