private void NotifyFileReadError(IFile file, Exception e) { FileReadError filereaderror = OnFileReadError; if (filereaderror != null) { filereaderror(file.Path, e); } }
//Try to read the file, while creating users/products and returning a list containing them all private List <T> ReadFile <T>(string path, Func <string, T> func) { List <T> liste = new List <T>(); try { liste = File.ReadLines(path).Skip(1).Select(line => func(line)).ToList(); } catch (Exception e) { FileReadError?.Invoke(e.Message); } return(liste); }