Ejemplo n.º 1
0
 private List <SearchResult> SearchFile(FileInfo file_info, string search_term, List <string> extensions_to_skip)
 {
     if (!extensions_to_skip.Contains(file_info.Extension.ToLower()))
     {
         List <SearchResult> results    = new List <SearchResult>();
         FileStream          filestream = new FileStream(file_info.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
         using (StreamReader streamreader = new StreamReader(filestream))
         {
             string line  = streamreader.ReadLine();
             int    count = 0;
             while (line != null)
             {
                 count++;
                 if (line.ToLower().Contains(search_term.ToLower()))
                 {
                     results.Add(new SearchResult
                     {
                         RelPath    = Path.GetDirectoryName(FilePathUtils.GetRelativePath(root_vertex.FilePath, file_info.FullName)),
                         FullPath   = file_info.FullName,
                         FileName   = file_info.Name,
                         Extension  = file_info.Extension,
                         LineNumber = count,
                         Line       = line.Length > 500 ? line.TrimStart().Substring(0, 500) : line.TrimStart()
                     });
                 }
                 line = streamreader.ReadLine();
             }
         }
         return(results);
     }
     return(null);
 }
Ejemplo n.º 2
0
 public FileVertex(string filename, string path, string root, TextDocument document) : base()
 {
     base.ID = Utils.IDCounter.Counter;
     //Document = new TextDocument();
     Document         = document;
     FileName         = FilePathUtils.GetRelativePath(root, path);
     FilePath         = path;
     LinesToHighlight = new List <int>();
     //StreamReader sr = new StreamReader(path);
     //Document.Text = sr.ReadToEnd();
 }