Settings
CsvFormatProvider allows to import and export CSV documents. Additionally, there are a number of settings that allow you to modify the import/export. The current article outlines the available settings.
CsvFormatProvider exposes a Settings property of type CsvSettings. This allows you to specify the following:
Delimiter: Gets or sets the list separator. By default the CsvFormatProvider class imports and exports files using the list separator specified by the current culture of the system.
Quote: Gets or sets the quote symbol.
HasHeaderRow: Specifies whether the document has a header row. The default value is false.
Encoding: Gets or sets the character encoding that is used when importing or exporting a file. The default value is UTF8 with BOM.
ShouldExportEmptyValues: Gets or Sets a value indicating whether the empty values are exported.
Example 1 shows how to create and specify a particular setting to a CsvFormatProvider.
Example 1: Use CsvSettings
CsvFormatProvider provider = new CsvFormatProvider();
provider.Settings.Delimiter = ';';
provider.Settings.Quote = '^';
provider.Settings.HasHeaderRow = true;
provider.Settings.Encoding = new UTF8Encoding();