private void MultiFileSelection() { if (MultipleFiles != null) { MultipleFiles.Clear(); } Microsoft.Win32.OpenFileDialog openDialog = new Microsoft.Win32.OpenFileDialog(); openDialog.Filter = "Data Files (*.hdf; *.txt)|*.hdf; *.txt|All Files (*.*)|*.*"; openDialog.Multiselect = true; openDialog.InitialDirectory = DirPath; List <string> files = new List <string>(); try { if (openDialog.ShowDialog() == true) { foreach (string fileName in openDialog.FileNames) { files.Add(System.IO.Path.GetFileName(fileName)); } MultipleFiles = files; DirPath = System.IO.Path.GetDirectoryName(openDialog.FileName); } } catch (Exception sroFileEx) { System.Diagnostics.Trace.WriteLine(DateTime.Now + "," + sroFileEx.ToString(), ",Please select valid SRO data files"); MultipleFiles = null; throw; } }
//================================================================ // Returns: Bunker Report File Paths from the given Directory //================================================================ public void FindBunkerReportFilePaths() { if (File.Exists(BunkerReportDirectoryPath)) { // This path is a file MessageBox.Show("This path is a file. Please choose a directory", "Comment", MessageBoxButtons.RetryCancel); DialogResult result = DialogResult.Retry; if (result == DialogResult.Retry) { // Regarding bunker report directory if (ActionOne == true || (!string.IsNullOrWhiteSpace(textBox1.Text))) { AcceptableBunkerDirectoryPath = false; } } } else if (Directory.Exists(BunkerReportDirectoryPath)) { int index; int sizeOfList; index = 0; // This path is a directory stringList = MultipleFiles.ProcessDirectory(BunkerReportDirectoryPath, index); sizeOfList = stringList.Count; AcceptableBunkerDirectoryPath = true; MultipleFiles.ProcessFile(BunkerReportDirectoryPath); } else { MessageBox.Show("Not a valid file or directory", "Comment", MessageBoxButtons.RetryCancel); DialogResult result = DialogResult.Retry; if (result == DialogResult.Retry) { AcceptableBunkerDirectoryPath = false; } } }