Export (0) Print
Expand All

File.AppendAllLines Method (String, IEnumerable<String>)

When it is called by trusted applications, appends lines to a file, and then closes the file.

Namespace:  System.IO
Assembly:  mscorlib (in mscorlib.dll)

public static void AppendAllLines(
	string path,
	IEnumerable<string> contents
)

Parameters

path
Type: System.String
The file to append the lines to. The file is created if it does not already exist.
contents
Type: System.Collections.Generic.IEnumerable<String>
The lines to append to the file.

ExceptionCondition
ArgumentException

path is a zero-length string, contains only white space, or contains one more invalid characters defined by the GetInvalidPathChars method.

ArgumentNullException

Either path or contents is null.

DirectoryNotFoundException

path is invalid (for example, it is on an unmapped drive).

FileNotFoundException

The file specified by path was not found.

IOException

An I/O error occurred while opening the file.

PathTooLongException

path exceeds 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.

NotSupportedException

path is in an invalid format.

SecurityException

The caller does not have permission to write to the file.

UnauthorizedAccessException

path specifies a file that is read-only.

-or-

This operation is not supported on the current platform.

-or-

path is a directory.

-or-

The caller does not have the required permission.

For more information about trusted applications, see Trusted Applications.

Silverlight

Supported in: 5, 4

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft