CSVReader.cs 557 B

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