Beispiel #1
0
        private static Encoding UwpEncodingToSystemEncoding(UwpUnicodeEncoding encoding)
        {
            switch (encoding)
            {
            case UwpUnicodeEncoding.Utf8:
                return(Encoding.UTF8);

            case UwpUnicodeEncoding.Utf16LE:
                return(Encoding.Unicode);

            case UwpUnicodeEncoding.Utf16BE:
                return(Encoding.BigEndianUnicode);
            }

            return(Encoding.UTF8);
        }
Beispiel #2
0
 /// <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 write 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 IAsyncAction WriteLinesAsync(IStorageFile file, IEnumerable <string> lines, UwpUnicodeEncoding encoding) =>
 WriteTextAsync(file, ConvertLinesToString(lines), encoding);
Beispiel #3
0
 /// <summary>
 /// Writes text to the specified file using the specified character encoding.
 /// </summary>
 /// <param name="file">The file that the text is written to.</param>
 /// <param name="contents">The text to write.</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 IAsyncAction WriteTextAsync(IStorageFile file, string contents, UwpUnicodeEncoding encoding) =>
 WriteTextTaskAsync(file, contents, append: false, encoding).AsAsyncAction();
Beispiel #4
0
 /// <summary>
 /// Reads the contents of the specified file using the specified character encoding and returns lines of text.
 /// </summary>
 /// <param name="file">The file to read.</param>
 /// <param name="encoding">The character encoding to use.</param>
 /// <returns>When this method completes successfully, it returns the contents of the file as a list
 /// (type <see cref="IList{string}" />) of lines of text. Each line of text in the list is represented
 /// by a <see cref="string"/> object.</returns>
 public static IAsyncOperation <IList <string> > ReadLinesAsync(IStorageFile file, UwpUnicodeEncoding encoding) =>
 ReadLinesTaskAsync(file, encoding).AsAsyncOperation();
Beispiel #5
0
 /// <summary>
 /// Reads the contents of the specified file using the specified character
 /// encoding and returns text.
 /// </summary>
 /// <param name="file">The file to read.</param>
 /// <param name="encoding">The character encoding to use.</param>
 /// <returns>When this method completes successfully, it returns the contents
 /// of the file as a text string.</returns>
 public static IAsyncOperation <string> ReadTextAsync(IStorageFile file, UwpUnicodeEncoding encoding) =>
 ReadTextTaskAsync(file, encoding).AsAsyncOperation();
Beispiel #6
0
Datei: FileIO.cs Projekt: x86/uno
 /// <summary>
 /// Writes text to the specified file using the specified character encoding.
 /// </summary>
 /// <param name="file">The file that the text is written to.</param>
 /// <param name="contents">The text to write.</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 IAsyncAction WriteTextAsync(IStorageFile file, string contents, UwpUnicodeEncoding encoding) =>
 AsyncAction.FromTask(cancellationToken => WriteTextTaskAsync(file, contents, append: false, recognizeEncoding: true, cancellationToken, encoding));
Beispiel #7
0
Datei: FileIO.cs Projekt: x86/uno
 /// <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 write 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 IAsyncAction WriteLinesAsync(IStorageFile file, IEnumerable <string> lines, UwpUnicodeEncoding encoding) =>
 AsyncAction.FromTask(cancellationToken => WriteLinesTaskAsync(file, lines, append: false, recognizeEncoding: true, cancellationToken, encoding));
Beispiel #8
0
Datei: FileIO.cs Projekt: x86/uno
 /// <summary>
 /// Reads the contents of the specified file using the specified character encoding and returns lines of text.
 /// </summary>
 /// <param name="file">The file to read.</param>
 /// <param name="encoding">The character encoding to use.</param>
 /// <returns>When this method completes successfully, it returns the contents of the file as a list
 /// (type <see cref="IList{string}" />) of lines of text. Each line of text in the list is represented
 /// by a <see cref="string"/> object.</returns>
 public static IAsyncOperation <IList <string> > ReadLinesAsync(IStorageFile file, UwpUnicodeEncoding encoding) =>
 AsyncOperation.FromTask(cancellationToken => ReadLinesTaskAsync(file, cancellationToken, encoding));
Beispiel #9
0
        public static async Task <bool> SaveFileAsync(StorageFile file, string content, Windows.Storage.Streams.UnicodeEncoding encoding)
        {
            // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
            CachedFileManager.DeferUpdates(file);
            // write to file
            await FileIO.WriteTextAsync(file, file.Name, encoding);

            // Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
            // Completing updates may require Windows to ask for user input.
            var status = await CachedFileManager.CompleteUpdatesAsync(file);

            return(status == FileUpdateStatus.Complete);
        }
Beispiel #10
0
 public static IAsyncOperation <IList <string> > ReadLinesAsync(string absolutePath, UwpUnicodeEncoding encoding) =>
 AsyncOperation.FromTask(cancellationToken => ReadLinesTaskAsync(absolutePath, cancellationToken, encoding));
Beispiel #11
0
 public static IAsyncAction AppendTextAsync(string absolutePath, string contents, UwpUnicodeEncoding encoding) =>
 AsyncAction.FromTask(cancellationToken => AppendTextTaskAsync(absolutePath, contents, cancellationToken, encoding));
Beispiel #12
0
 public static IAsyncAction AppendLinesAsync(string absolutePath, IEnumerable <string> lines, UwpUnicodeEncoding encoding) =>
 AsyncAction.FromTask(cancellationToken => AppendLinesTaskAsync(absolutePath, lines, cancellationToken, encoding));