Skip to content

Commit

Permalink
Use AppendLines instead AppendText
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel0024 committed Jul 11, 2024
1 parent 67fa8c5 commit 00f92cf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions CocoCrawler/CrawlOutputs/CsvFileCrawlOutput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public virtual async Task WriteAsync(JObject jObject, CancellationToken cancella

try
{
// Add headers
// Add headers if new file
if (!File.Exists(filePath))
{
var headers = string.Join(",", jObject.Properties().Select(p => p.Name));
await File.WriteAllTextAsync(filePath, headers + Environment.NewLine, cancellationToken);
await File.AppendAllLinesAsync(filePath, [headers], cancellationToken);
}

await File.AppendAllTextAsync(filePath, csv + Environment.NewLine, cancellationToken);
await File.AppendAllLinesAsync(filePath, [csv], cancellationToken);
}
finally
{
Expand Down

0 comments on commit 00f92cf

Please sign in to comment.