Как искать символ в имени файла?
Уважаемые Эксперты,
Проблема: после пакетной загрузки файлов мне нужно распознать и отсортировать файлы по именам (по маске или флагу). Например, имя файла "Tripolskoe_23_2341_MD_123-XXX.PDF". Моя утилита должна распознать имя файла и определить этот файл по флагу "MD". Какое условие для поиска следует поставить? Какой код я могу использовать в моем случае?
С уважением,
Дарья
Что я уже пробовал:
private void DropSpot_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { // We only want to accept files, so we only set our DragDropEffects // if that's what's being dragged in if (e.Data.GetDataPresent(DataFormats.FileDrop, false)==true) { e.Effect = DragDropEffects.All; } } ArrayList Files = new ArrayList(); private void DropSpot_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { // Get a list of all objects in the Drop Data, that are files string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); // Iterate through the dropped files for (int i=0;i<files.Length;i++) { // Add the to our ArrayList Files.Add(files[i]); // Create our new List View item ListViewItem item = new ListViewItem(); // Get a file info object // we use this for getting file size, etc. System.IO.FileInfo fInfo = new System.IO.FileInfo(files[i]); item.Text = System.IO.Path.GetFileName(fInfo.Name); item.SubItems.Add(fInfo.Length.ToString()); item.SubItems.Add("Pending"); FileListView.Items.Add(item); FileListView.Tag = Files[Files.Count-1]; } // Refresh the file list - for good measure this.Refresh(); // If we added files, clear the instruction label }