public void AddResponseDocument() { if (openFileDialog.ShowDialog() == DialogResult.OK) { string filepath = openFileDialog.FileName; if (!filepath.NullOrEmpty() && File.Exists(filepath)) { FileInfo fi = new FileInfo(filepath); if (fi.Length > int.MaxValue) { MessageBox.Show("The file is too large. Please select a file smaller than " + Int32.MaxValue.ToString("0,000,000,000") + " bytes.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Properties.Settings.Default.AddFileInitialFolder = fi.DirectoryName; Properties.Settings.Default.Save(); processor.AddResponseDocument(requestId, filepath); documents = processor.Response(requestId); FileListDataSource = documents; ShowView = DisplayType.FILELIST; } } } }
public void AddResponseDocument(Action <IEnumerable <Document> > addToCache = null) { if (openFileDialog.ShowDialog() == DialogResult.OK) { string filepath = openFileDialog.FileName; if (!filepath.NullOrEmpty() && File.Exists(filepath)) { FileInfo fi = new FileInfo(filepath); if (fi.Length > int.MaxValue) { MessageBox.Show("The file is too large. Please select a file smaller than " + Int32.MaxValue.ToString("0,000,000,000") + " bytes.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Properties.Settings.Default.AddFileInitialFolder = fi.DirectoryName; Properties.Settings.Default.Save(); processor.AddResponseDocument(requestId, filepath); var docs = processor.Response(requestId); if (addToCache != null && _cache.Enabled) { addToCache(new[] { docs.LastOrDefault() }); documents = documents.Concat(docs).ToArray(); FileListDataSource = _cache.GetResponseDocuments(); } else { documents = docs; FileListDataSource = documents; } ShowView = DisplayType.FILELIST; } } } }