InTheHand.Storage.PathIO.AppendTextAsync C# (CSharp) Method

AppendTextAsync() public static method

Appends text to the file at the specified path or URI.
public static AppendTextAsync ( string absolutePath, string contents ) : System.Threading.Tasks.Task
absolutePath string The path of the file that the text is appended to.
contents string The text to append.
return System.Threading.Tasks.Task
        public static Task AppendTextAsync(string absolutePath, string contents)
        {
            return AppendTextAsync(absolutePath, contents, UnicodeEncoding.Utf8);
        }

Same methods

PathIO::AppendTextAsync ( string absolutePath, string contents, UnicodeEncoding encoding ) : System.Threading.Tasks.Task

Usage Example

示例#1
0
文件: FileIO.cs 项目: baskren/Pontoon
        /// <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
        }