By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,490 Members | 1,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,490 IT Pros & Developers. It's quick & easy.

Problem about StreamReader and StreamWriter

P: n/a
See the code below, var 'content ' is suppose to be "Hello!", not "". Who
knows why? Thanks
string text = "hello!";

MemoryStream stream = new MemoryStream();

StreamWriter streamWriter = new StreamWriter(stream, Encoding.ASCII);



StreamReader streamReader = new StreamReader(stream);

string content = "";



content = streamReader.ReadToEnd();

}//content =""






Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Hi RL,

Well, you have two errors in your code. Uncomment the StreamWriter.Flush
and reset the MemoryStream position which will be at the end of the text
when you write to it.

StreamReader.BaseStream.Position = 0;

Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.