/// <summary>
/// Writes lines of text to the specified file using the specified character encoding.
/// </summary>
/// <param name="file">The file that the lines are written to.</param>
/// <param name="lines">The list of text strings to append as lines.</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 WriteLinesAsync(IStorageFile file, IEnumerable <string> lines, UnicodeEncoding encoding)
{
#if __ANDROID__ || __UNIFIED__ || WIN32 || TIZEN
return(PathIO.WriteLinesAsync(file.Path, lines, encoding));
#elif WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81
return(Windows.Storage.FileIO.WriteLinesAsync((Windows.Storage.StorageFile)((StorageFile)file), lines, (Windows.Storage.Streams.UnicodeEncoding)((int)encoding)).AsTask());
#elif WINDOWS_PHONE
return(Task.Run(async() =>
{
Stream s = await file.OpenStreamForWriteAsync();
using (StreamWriter sw = new StreamWriter(s, UnicodeEncodingHelper.EncodingFromUnicodeEncoding(encoding)))
{
foreach (string line in lines)
{
sw.WriteLine(line);
}
}
}));
#else
throw new PlatformNotSupportedException();
#endif
}