I am saving a downloaded file to isolated storage, I would like to set the encoding to iso-8859-1 since the xml file I’m downloading is encoded that way.
var stream = new IsolatedStorageFileStream("myfile.xml", FileMode.Create, FileAccess.Write, myIsolatedStorage);
using (StreamWriter writeFile = new StreamWriter(stream)) {
string xml_file = e.Result.ToString();
writeFile.WriteLine(xml_file);
writeFile.Close();
}
The ideal solution would be to download the file as a stream and saving it directly to file, thus maintaining the downloaded bytes as is (so no text encoding conversion would be required)!
Also, Windows Phone only supports a few basic text encodings like UTF8 and Unicode; in order to use another encoding in WP, you’ll have to use the Silverlight Text Encoding Generator tool!