/// <summary> /// Action for the File->Open command. /// </summary> /// public void Open_Execute(object sender) { var dlg = new OpenFileDialog() { FileName = "Sample", DefaultExt = ".csv", Filter = loadFormats.GetFilterString(true), FilterIndex = loadFormats.IndexOf("*.csv") + 1, InitialDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources\\Samples\\") }; if (!String.IsNullOrEmpty(lastSavePath)) { dlg.InitialDirectory = lastSavePath; } // Show open file dialog box var result = dlg.ShowDialog(); if (result == true) { // Get the chosen format var fmt = loadFormats[dlg.FilterIndex - 1]; DataTable table = fmt.Read(new FileStream(dlg.FileName, FileMode.Open)); double[][] values = table.ToJagged(); Values.Clear(); foreach (double[] row in values) { var sample = new SampleViewModel(); sample.Value = row[0]; if (row.Length > 1) { sample.Weight = row[1]; } Values.Add(sample); } } }