CsvFileWriter
Class for writing to comma-separated-value (CSV) files.
Hereda de: CsvFileCommon
Implementa: IDisposable, IAsyncCommitable
Constructores
public CsvFileWriter(Stream stream, Encoding encoding)
csvFileWriter = CsvFileWriter(stream, encoding)
Initializes a new instance of the CsvFileWriter class for the specified stream.
- stream
- The stream to write to
- encoding
- The text encoding.
public CsvFileWriter(string path)
csvFileWriter = CsvFileWriter(path)
Initializes a new instance of the CsvFileWriter class for the specified file path.
- path
- The name of the CSV file to write to
public CsvFileWriter(StreamWriter writer)
csvFileWriter = CsvFileWriter(writer)
Initializes a new instance of the CsvFileWriter class for the specified writer.
- writer
- StreamWriter
Propiedades
public override Stream BaseStream { get; }
value = csvFileWriter.BaseStream
Gets the underlying stream.
public string LineSeparator { get; set; }
value = csvFileWriter.LineSeparator
csvFileWriter.LineSeparator = value
Gets or sets the character used to separate lines in the CSV file.
Métodos
public ValueTask CommitAsync(CancellationToken cancellationToken)
result = csvFileWriter.CommitAsync(cancellationToken)
Asynchronously commits the transaction by flushing data and propagating commit to the underlying stream if it supports transactions.
- cancellationToken
- CancellationToken
Devuelve: Task
protected override void DisposeManaged()
csvFileWriter.DisposeManaged()
Disposes the managed resources. Override this method to add custom clean up of managed resources.
public string Encode(string column)
result = csvFileWriter.Encode(column)
Encodes a column's value for output.
- column
public Task FlushAsync(CancellationToken cancellationToken)
result = csvFileWriter.FlushAsync(cancellationToken)
Asynchronously flushes the writer.
- cancellationToken
- CancellationToken
Devuelve: Task
public void Truncate()
csvFileWriter.Truncate()
Truncates the underlying stream used by the CsvFileWriter by clearing its content.
public ValueTask WriteRowAsync(IEnumerable<string> columns, CancellationToken cancellationToken)
result = csvFileWriter.WriteRowAsync(columns, cancellationToken)
Asynchronously writes a row of columns to the current CSV file.
- columns
- The list of columns to write
- cancellationToken
- CancellationToken
Devuelve: ValueTask