public static void Save<TSource>(
IEnumerable<TSource> data,
string filePath,
CsvFrom<TSource> converter,
char delimiter = ',',
Encoding? textEncoding = null,
IReadOnlyCollection<string?>? columnNames = null
)
Public Shared Sub Save(Of TSource) (
data As IEnumerable(Of TSource),
filePath As String,
converter As CsvFrom(Of TSource),
Optional delimiter As Char = ","C,
Optional textEncoding As Encoding = Nothing,
Optional columnNames As IReadOnlyCollection(Of String) = Nothing
)
public:
generic<typename TSource>
static void Save(
IEnumerable<TSource>^ data,
String^ filePath,
CsvFrom<TSource>^ converter,
wchar_t delimiter = L',',
Encoding^ textEncoding = nullptr,
IReadOnlyCollection<String^>^ columnNames = nullptr
)
static member Save :
data : IEnumerable<'TSource> *
filePath : string *
converter : CsvFrom<'TSource> *
?delimiter : char *
?textEncoding : Encoding *
?columnNames : IReadOnlyCollection<string>
(* Defaults:
let _delimiter = defaultArg delimiter ','
let _textEncoding = defaultArg textEncoding null
let _columnNames = defaultArg columnNames null
*)
-> unit
A collection of column names for the header to be written, or null to use the PropertyNames of the CsvMapping as column names.
The collection determines the order in which the columns appear in the CSV file.
The collection will be copied. If the collection contains null values, empty strings, or white space, these are replaced by automatically generated column names. Column names cannot appear twice. By default the comparison is case-sensitive but it will be reset to a case-insensitive comparison if the column names are also unique when treated case-insensitive.
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.
ArgumentNullException | data, or filePath, or converter is null. |
ArgumentException | filePath is not a valid file path. - or - columnNames is not null and a column name in columnNames occurs twice. |
IOException | I/O error. |