Skip to content

Commit 6aa878c

Browse files
Tino KlijnDotNet2Web
authored andcommitted
using the delimiter when writing a errors.csv
1 parent 687f754 commit 6aa878c

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CsvCore/Reader/CsvCoreReader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public IEnumerable<T> Read<T>(string filePath)
158158
var errorFile = Path.GetFileNameWithoutExtension(filePath);
159159

160160
new CsvCoreWriter()
161+
.UseDelimiter(char.Parse(delimiter))
161162
.Write(Path.Combine(errorFolderPath, $"{errorFile}_errors.csv"), validationResults);
162163

163164
return result;

CsvCore/Writer/CsvCoreWriter.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ public void Write<T>(string filePath, IEnumerable<T> records) where T : class
3232

3333
try
3434
{
35+
// Ensure the directory exists
36+
var directory = Path.GetDirectoryName(filePath);
37+
38+
if (!Directory.Exists(directory))
39+
{
40+
Directory.CreateDirectory(directory!);
41+
}
42+
3543
using var writer = new StreamWriter(filePath);
3644
var properties = typeof(T).GetProperties();
3745

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
[![open issues](https://img.shields.io/github/issues/DotNet2Web/csvcore)](https://github.com/DotNet2Web/csvcore/issues)
2121
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
2222
![](https://img.shields.io/badge/release%20strategy-githubflow-orange.svg)
23-
![Static Badge](https://img.shields.io/badge/8.0%2C_9.0-dummy?label=dotnet&color=%235027d5)
23+
![Static Badge](https://img.shields.io/badge/6.0%2C_8.0%2C_9.0-dummy?label=dotnet&color=%235027d5)
2424

2525
<a href="#about">About</a> •
2626
<a href="#how-to-use-it">How To Use</a> •

0 commit comments

Comments
 (0)