Jay B. Harlow said:
Hayato,
You cannot convert the String to a Stream per se.
However! You can use the StringReader & StringWriter to read from & write to
a String. If your IO routines expect TextReader & TextWriter you can then
use Strings & Streams interchangeable. As TextReader is the base class for
both StreamReader & StringReader. Same with TextWriter and StreamWriter &
StringWriter.
With the aid of the System.Text.Encoding class you could convert the String
into an Array of Bytes, which you can pass to the constructor of
MemoryStream.
Of course you are free to inherit from Stream to create a StringStream
class.
The StringReader & StringWriter is my first choice, then I use the others as
appropriate.
Hope this helps
Jay