/// <summary>
/// Appends text to the specified file using the specified character encoding.
/// </summary>
/// <param name="file">The file that the text is appended to.</param>
/// <param name="contents">The text to append.</param>
/// <param name="encoding">The character encoding of the file.</param>
/// <returns>No object or value is returned when this method completes.</returns>
public static Task AppendTextAsync(IStorageFile file, string contents, UnicodeEncoding encoding)
{
#if __ANDROID__ || __UNIFIED__ || WIN32 || TIZEN
return(PathIO.AppendTextAsync(file.Path, contents, encoding));
#elif WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81
return(Windows.Storage.FileIO.AppendTextAsync((Windows.Storage.StorageFile)((StorageFile)file), contents, (Windows.Storage.Streams.UnicodeEncoding)((int)encoding)).AsTask());
#elif WINDOWS_PHONE
return(Task.Run(async() =>
{
Stream s = await file.OpenStreamForWriteAsync();
s.Position = s.Length;
using (StreamWriter sw = new StreamWriter(s, UnicodeEncodingHelper.EncodingFromUnicodeEncoding(encoding)))
sw.Write(contents);
}));
#else
throw new PlatformNotSupportedException();
#endif
}