|
-
September 22nd, 2004, 04:10 AM
#1
System.IO.Stream ?
How to convert string or StringBuilder to System.IO.Stream using C# ?
pls guide
-
September 22nd, 2004, 06:05 AM
#2
Re: System.IO.Stream ?
What are you trying to do exactly ?
You can WRITE and READ from streams, not 'convert'.
e.g.
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();
Similarly to read from a stream you can do :
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();
Darwen.
-
September 23rd, 2004, 07:40 PM
#3
Re: System.IO.Stream ?
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|