Created
June 6, 2016 13:57
-
-
Save BrianJVarley/642d2a76c68804a8ad58db967a3157c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task<ObservableCollection<ZoneInfo>> ReadZones(string tableName) | |
| { | |
| string fileName = string.Format("{0}.csv", tableName); | |
| // access the local folder | |
| StorageFolder appFolder = | |
| Windows.ApplicationModel.Package.Current.InstalledLocation; | |
| Stream fileStream = await appFolder.GetFileAsync().OpenStreamForReadAsync(fileName); | |
| using (var textReader = new StreamReader(fileStream)) | |
| { | |
| ObservableCollection<ZoneInfo> zoneInfoCollection = new ObservableCollection<ZoneInfo>(); | |
| try | |
| { | |
| var csvReader = new CsvReader(textReader); | |
| csvReader.Read(); | |
| List<ZoneInfo> zoneInfo = csvReader.GetRecords<ZoneInfo>().ToList(); | |
| zoneInfoCollection = new ObservableCollection<ZoneInfo>(zoneInfo); ; | |
| return zoneInfoCollection; | |
| } | |
| catch(CsvReaderException ex) | |
| { | |
| return zoneInfoCollection; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment