System.IO.Abstractions.FileBase.WriteAllLines C# (CSharp) Méthode

WriteAllLines() public abstract méthode

Creates a new file, writes a collection of strings to the file, and then closes the file.

If the target file already exists, it is overwritten.

You can use this method to create the contents for a collection class that takes an IEnumerable{T} in its constructor, such as a List{T}, HashSet{T}, or a SortedSet{T} class.

is a zero-length string, contains only white space, or contains one or more invalid characters as defined by . Either or is . The specified path is invalid (for example, it is on an unmapped drive). The file specified in was not found. An I/O error occurred while opening the file. /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// is in an invalid format. The caller does not have the required permission. /// specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// specified a directory. /// -or- /// The caller does not have the required permission. ///
public abstract WriteAllLines ( string path, IEnumerable contents ) : void
path string The file to write to.
contents IEnumerable The lines to write to the file.
Résultat void
        public abstract void WriteAllLines(string path, IEnumerable<string> contents);

Same methods

FileBase::WriteAllLines ( string path, IEnumerable contents, Encoding encoding ) : void
FileBase::WriteAllLines ( string path, string contents ) : void
FileBase::WriteAllLines ( string path, string contents, Encoding encoding ) : void