CsvOpenWrite(String, Int32, Char, Encoding) Method

Initializes a CsvWriter to write a CSV file without header row.

Definition

Namespace: FolkerKinzel.CsvTools
Assembly: FolkerKinzel.CsvTools (in FolkerKinzel.CsvTools.dll) Version: 2.0.1+2345335399184346d9b2cc992ed5c814406052c1
C#
public static CsvWriter OpenWrite(
	string filePath,
	int columnsCount,
	char delimiter = ',',
	Encoding? textEncoding = null
)

Parameters

filePath  String
File path of the CSV file.
columnsCount  Int32
Number of columns in the CSV file.
delimiter  Char  (Optional)
The field separator character.
textEncoding  Encoding  (Optional)
The text encoding to be used or null for UTF8.

Return Value

CsvWriter
A CsvWriter instance that allows you to write data as a CSV file.

Remarks

Creates a new CSV file. If the target file already exists, it is truncated and overwritten.

When exchanging CSV data with Excel, the appropriate arguments can be determined with GetExcelArguments.

Exceptions

ArgumentNullExceptionfilePath is null.
ArgumentExceptionfilePath is not a valid file path.
ArgumentOutOfRangeException

columnsCount is negative.

- or -

delimiter is either the double quotes " or a line break character ('\r' or '\n').

IOExceptionI/O error.

See Also