Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

Save a stream as a string

$
0
0

Hello,
I would like to save a stream as a string. I am converting it to a stream like this:

    public string StreamToString(Stream s)
    {
        s.Position = 0;
        StreamReader reader = new StreamReader(s);
        string text = reader.ReadToEnd();

        return text;
    }

and plan to save it in Xam.plugins.settings.
However, when I view the string in debugging it comes back as "????"(Question marks in triangles).

The stream represents an image.

Here is how I am converting it back:

    private MemoryStream StringToStream(string value)
    {
        MemoryStream stream = new MemoryStream();
        StreamWriter writer = new StreamWriter(stream);
        writer.Write(value);
        writer.Flush();

        return stream;
    }

Thank you for your help!


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>