How to convert string or StringBuilder to System.IO.Stream using C# ?
pls guide
Printable View
How to convert string or StringBuilder to System.IO.Stream using C# ?
pls guide
What are you trying to do exactly ?
You can WRITE and READ from streams, not 'convert'.
e.g.
Similarly to read from a stream you can do :Code:string sHelloThere = "Hello there";
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream);
writer.Write(sHelloThere);
writer.Close();
Darwen.Code:byte [] abData = // from wherever
System.IO.MemoryStream stream = new System.IO.MemoryStream(abData);
System.IO.BinaryReader reader = new System.IO.BinaryReader(stream);
string sRead = reader.ReadString();
reader.Close();
Hello
Thanks for reply.
Well, I am trying to load a file in Rich text box using
RichTextBox.LoadFile Method (Stream, RichTextBoxStreamType)
but my data is in string format (I am generating an RTF file at runtime), thats why i want to convert it in to stream
please guide
regards