In C#, to convert a String into a Stream object, we need to use the GetBytes method (from the Encoding.ASCII package), this way:
byte[] bytes = Encoding.ASCII.GetBytes(xmlContent); |
And then, use that byte array when instantiate a Stream (for example, MemoryStream or FileStream):
MemoryStream stream = new MemoryStream(bytes); |