Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 447 Bytes

create-a-stream-from-string.md

File metadata and controls

18 lines (15 loc) · 447 Bytes

Create a stream from string

Use this function:

public static Stream GenerateStreamFromString(string s)
{
    var stream = new MemoryStream();
    var writer = new StreamWriter(stream);
    writer.Write(s);
    writer.Flush();
    stream.Position = 0;
    return stream;
}

Don't forget to close the stream after using it.

Got it from here