How can I convert string into Stream or object into Stream (using C#.Net)?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ritesh Diyawar101 reputationPosted Oct 8, 2012, 2:07 AM EDT
Hi Yin U can try this code: string test = "String to Stream Conversion"; // convert string to stream byte[] byteArray = Encoding.ASCII.GetBytes( test ); // GetyBytes method is used to to create a byte array MemoryStream stream = new MemoryStream( byteArray ); // convert stream to string // stream reader object created StreamReader reader = new StreamReader( stream ); // complete streams read by Read to end method // of stream reader class string text = reader.ReadToEnd(); Console.WriteLine(text); Console.ReadLine();