CSVReader.cs 529 B

123456789101112131415161718192021222324
  1. namespace Universal;
  2. public class BasicCSVReader
  3. {
  4. public static bool ReadCSV(string filePath, out List<string[]> fields)
  5. {
  6. fields = [];
  7. if (!File.Exists(filePath))
  8. return false;
  9. try
  10. {
  11. using var reader = new StreamReader(filePath);
  12. string? line;
  13. while ((line = reader.ReadLine()) is not null)
  14. fields.Add(line.Split(','));
  15. }
  16. catch
  17. {
  18. return false;
  19. }
  20. return true;
  21. }
  22. }