Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit b1f08896 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

open csv files read-only

parent 5de119c6
No related branches found
No related tags found
No related merge requests found
...@@ -75,7 +75,7 @@ namespace TUGraz.VectoCore.Utils ...@@ -75,7 +75,7 @@ namespace TUGraz.VectoCore.Utils
public static TableData Read(string fileName, bool ignoreEmptyColumns = false, bool fullHeader = false) public static TableData Read(string fileName, bool ignoreEmptyColumns = false, bool fullHeader = false)
{ {
try { try {
using (var fs = new FileStream(fileName, FileMode.Open)) { using (var fs = new StreamReader(File.OpenRead(fileName))) {
var retVal = new TableData(fileName); var retVal = new TableData(fileName);
ReadCSV(retVal, fs, ignoreEmptyColumns, fullHeader); ReadCSV(retVal, fs, ignoreEmptyColumns, fullHeader);
return retVal; return retVal;
...@@ -98,11 +98,11 @@ namespace TUGraz.VectoCore.Utils ...@@ -98,11 +98,11 @@ namespace TUGraz.VectoCore.Utils
string source = null) string source = null)
{ {
var retVal = new TableData(source, DataSourceType.Embedded); var retVal = new TableData(source, DataSourceType.Embedded);
ReadCSV(retVal, stream, ignoreEmptyColumns, fullHeader); ReadCSV(retVal, new StreamReader(stream), ignoreEmptyColumns, fullHeader);
return retVal; return retVal;
} }
private static void ReadCSV(DataTable table, Stream stream, bool ignoreEmptyColumns, bool fullHeader) private static void ReadCSV(DataTable table, StreamReader stream, bool ignoreEmptyColumns, bool fullHeader)
{ {
var p = new TextFieldParser(stream) { var p = new TextFieldParser(stream) {
TextFieldType = FieldType.Delimited, TextFieldType = FieldType.Delimited,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment