Monday, 28 January 2013

Converting Stream to String and String to Bytes

C# : Converting Stream to String and  String to Bytes

Following code can be sued for converting stream to string and then stream to bytes.

Stream Stream1 = bodyPart.GetOriginalDataStream();
                            String test = new StreamReader(Stream1).ReadToEnd();                            System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
                            Byte[] bytes = encoding.GetBytes(test);

No comments:

Post a Comment