AppendAllLines() public static méthode

public static AppendAllLines ( String path, IEnumerable contents ) : void
path String
contents IEnumerable
Résultat void
Exemple #1
0
        public void NotifySuiteFinalized(string name, bool passed, int runtime)
        {
            Response.ContentType = "text/plain";
            lock (IO_SYNC)
            {
                if (passed && _runFlags.IsContinuousIntegration)
                {
                    IOFile.AppendAllLines(_completedSuitesFileName, new[] { name });
                }
                ConsoleHelper.Write("[");
                if (passed)
                {
                    ConsoleHelper.Write(" OK ", ConsoleColor.Green);
                }
                else
                {
                    ConsoleHelper.Write("FAIL", ConsoleColor.Red);
                }

                TimeSpan runSpan = TimeSpan.FromMilliseconds(runtime);
                ConsoleHelper.WriteLine($"] {name} in {Math.Round(runSpan.TotalSeconds, 3)}s");

                NotifyIsAlive();
            }
        }
    /// <summary>
    ///     Asynchronously appends lines of text to a specified file path.
    /// </summary>
    /// <param name="path">The path of the file.</param>
    /// <param name="contents">The contents.</param>
    /// <param name="encoding">The encoding to use.</param>
    /// <param name="cancellationToken">The cancellation token to stop this operation.</param>
    /// <returns>A task representing the current operation.</returns>
    /// <exception cref="ArgumentNullException">
    ///     <paramref name="path" /> or <paramref name="contents" /> is
    ///     <see langword="null" /> (<see langword="Nothing" /> in Visual Basic).
    /// </exception>
    /// <remarks>
    ///     This operation always requires an encoding to be used. If <paramref name="encoding" /> is set to
    ///     <see langword="null" />, an implementation-specific
    ///     encoding will be used.
    /// </remarks>
    public Task AppendAllLinesAsync(
        string path,
        IEnumerable <string> contents,
        Encoding?encoding = null,
        CancellationToken cancellationToken = default)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));
        _ = Requires.NotNull(
            contents,
            nameof(contents));

        return(encoding == null
            ? Work.OnThreadPoolAsync(
                   state => FSFile.AppendAllLines(
                       state.Path,
                       state.Contents),
                   (Path : path, Contents : contents),
                   cancellationToken)
               : Work.OnThreadPoolAsync(
                   state => FSFile.AppendAllLines(
                       state.Path,
                       state.Contents,
                       state.Encoding),
                   (Path : path, Contents : contents, Encoding : encoding),
                   cancellationToken));
    }
    /// <summary>
    ///     Appends lines of text to a specified file path.
    /// </summary>
    /// <param name="path">The path of the file.</param>
    /// <param name="contents">The contents.</param>
    /// <param name="encoding">The encoding to use.</param>
    /// <exception cref="ArgumentNullException">
    ///     <paramref name="path" /> or <paramref name="contents" /> is <see langword="null" /> (<see langword="Nothing" /> in
    ///     Visual Basic).
    /// </exception>
    /// <remarks>
    ///     This operation always requires an encoding to be used. If <paramref name="encoding" /> is set to
    ///     <see langword="null" />, an implementation-specific
    ///     encoding will be used.
    /// </remarks>
    public void AppendAllLines(
        string path,
        IEnumerable <string> contents,
        Encoding?encoding = null)
    {
        _ = Requires.NotNullOrWhiteSpace(
            path,
            nameof(path));
        _ = Requires.NotNull(
            contents,
            nameof(contents));

        if (encoding == null)
        {
            FSFile.AppendAllLines(
                path,
                contents);
        }
        else
        {
            FSFile.AppendAllLines(
                path,
                contents,
                encoding);
        }
    }
Exemple #4
0
 public void Append([NotNull] IEnumerable <string> contents)
 => F.AppendAllLines(this.FullName, contents);
Exemple #5
0
 public void AppendAllLines(IEnumerable <string> contents, Encoding encoding) => File.AppendAllLines(Internal, contents, encoding);
Exemple #6
0
 public void AppendAllLines(IEnumerable <string> contents) => File.AppendAllLines(Internal, contents);