Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the use of CsvReader after CsvDataReader is disposed. #2175

Open
Qwertyluk opened this issue Aug 15, 2023 · 0 comments · May be fixed by #2227
Open

Allow the use of CsvReader after CsvDataReader is disposed. #2175

Qwertyluk opened this issue Aug 15, 2023 · 0 comments · May be fixed by #2227
Labels

Comments

@Qwertyluk
Copy link

Qwertyluk commented Aug 15, 2023

Is your feature request related to a problem? Please describe.
Allow the use of CsvReader after CsvDataReader is disposed.

Describe the solution you'd like
Add CsvDataReader constructor parameter leaveOpen with default value false to decide whether CsvReader should be disposed together with CsvDataReader.

public CsvDataReader(CsvReader csv, DataTable? schemaTable = null, bool leaveOpen = false)
{
	//ctor
}

Additional context
Currently, there is no way to prevent CsvReader from being disposed when CsvDataReader is disposed.
It would be nice to have such an option and be able to reuse CsvReader after CsvDataReader is diposed:

using (var reader = new StreamReader("path\\to\\file.csv"))
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
{
	using (var dr = new CsvDataReader(csv))
	{
		// do somework with CsvDataReader
		dr.Read();
	}

	// right now, can't reuse CsvReader here because it is already disposed
	//csv.Read();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant