Exemplo n.º 1
0
 public void StartFindSubString()
 {
     if(CurrentField.FieldView.SelectedItems.Count != 1)
         return;
     int fileIndex = CurrentField.FieldView.Items.IndexOf(CurrentField.FieldView.SelectedItems[0]);
     var findSubStringForm = new FindSubStringForm(CurrentField.FieldElementList[fileIndex].Path, this);
     findSubStringForm.ShowDialog();
 }
Exemplo n.º 2
0
 public void FindSubString(string subString, string filePath, FindSubStringForm findSubStringForm)
 {
     if (!System.IO.File.Exists(filePath) || String.IsNullOrEmpty(subString))
         return;
     var file = new FileInfo(filePath);
     if (!file.Exists || !String.Equals(file.Extension, ".txt"))
         return;
     StreamReader fileStream = new StreamReader(file.FullName, Encoding.Default);
     string buffer = null;
     int line = 1;
     while ((buffer = fileStream.ReadLine()) != null)
     {
         if (buffer.Contains(subString))
             findSubStringForm.AddResult(buffer, subString, line);
         line++;
     }
     fileStream.Close();
 }