I am using a tcpstream and copied the data into memorystream. Now i would like to convert it to a text (UTF-8 encoded). I tried various ways and did flush() but i could not figured it out. I tried using it in combination with StreamReader with no luck (i get a empty string).
Share
Just get the data from the
MemoryStreamand decode it:It’s likely that you get an empty string because you are reading from the
MemoryStreamwithout resetting it’s position. TheToArraymethod gets all the data regardless of where the current positon is.If it happens to be a byte array before you put it in the
MemoryStream, you can just use that directly.