public void DownloadCsv() { var newFileName = ApplicationController.GetSaveFileName(string.Format("{0}", RecordService.GetCollectionName(RecordType)), "csv"); ApplicationController.DoOnAsyncThread(() => { try { LoadingViewModel.IsLoading = true; if (!string.IsNullOrWhiteSpace(newFileName)) { var folder = Path.GetDirectoryName(newFileName); var fileName = Path.GetFileName(newFileName); var fields = FieldMetadata.Select(rf => rf.FieldName); CsvUtility.CreateCsv(folder, fileName, GetGridRecords(true).Records, fields, (f) => RecordService.GetFieldLabel(f, RecordType), (r, f) => { return(RecordService.GetFieldAsDisplayString((IRecord)r, f)); }); ApplicationController.StartProcess("explorer.exe", "/select, \"" + Path.Combine(folder, fileName) + "\""); } } catch (Exception ex) { ApplicationController.UserMessage("Error Downloading CSV: " + ex.DisplayString()); } finally { LoadingViewModel.IsLoading = false; } }); }