473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to convert a Stream to a String

ad
I have a Steam, it read from a text file.
How can I convert this Stream to a String?
May 16 '06 #1
4 1602
What kind of stream? You should be able to use a StreamReader to get
the contents of the stream.

May 16 '06 #2
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
5
by: jk | last post by:
I'm having trouble converting a datatable into xml, with resonse.write to aspx. I'm basically converting vb code that saved a recordset into a stream into c#, but the format is wrong. I've tried...
2
by: Brian | last post by:
I have a string that I received from a web service call and I want to write it to a Stream. I cannot figure out how to access the string as a byte array and write it to the Stream. Any thoughts. I...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
6
by: hb | last post by:
Hi, Would you please give me some idea to convert/decode a Base 64 encoded GIF image string to a *.gif file in ASP.Net? Thank you hb
10
by: Nikolay Petrov | last post by:
How can I convert DOS cyrillic text to Unicode
3
by: Ursula | last post by:
Is it possible to convert a string in a file. The problem is this: I have an object string that is a file xml and I want to pass to Deserialize function, but Deserialize function expect an object...
2
by: Robert Dufour | last post by:
I got a stream from a file, could be any document type like doc or txt. I want to convert it to a string variable so that I can replace some custom tag contents in it's text with text values...
0
by: jeff_rowa | last post by:
Hi guyz, Could anyone please tell me how can I convert an array of floats to a string? I know that I can use this code to convert one float to a string but what is the best way for an array of...
11
by: Sudzzz | last post by:
Hi, I'm trying to convert a string something like this "{201,23,240,56,23,45,34,23}" into an array in C++ Please help. Thanks, Sudzzz
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.