Read All Text from Textfile with Encoding in Windows RT
A simple extension for reading all text from a text file in WinRT with a specific encoding, made as an extension to StorageFile:
public static class StorageFileExtensions
{
async public static Task<string> ReadAllTextAsync(this StorageFile storageFile)
{
var buffer = await FileIO.ReadBufferAsync(storageFile);
var fileData = buffer.ToArray();
var encoding = Encoding.GetEncoding("Windows-1252");
var text = encoding.GetString(fileData, 0, fileData.Length);
return text;
}
}