Pixel-ink
Pixel-ink
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
Yeah, figure that. But, all my code was working before I posted for help. But the old code only returedn one line per file that had matching term. I want all lines in each file that matches term searched for.
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
Also, I added your code suggestion. I get no errors, but I get no results either and my App freeze so that I have to "End Tasks"
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
Okay, didn't know. Cool. I added CS to the post... looks nice
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
I did basically do that. Except the "CS" string part
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
Well, I am just letting you know why I thought the code you posted was old.
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
Yeah it is. Sorry I had a stroke a few years back and have brain damage, so my attention is problematic and slow.
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
Lastest code:
string dirScanner = (GlobalVar.dataPath);
if (string.IsNullOrWhiteSpace("DateTime.Now"))
return;

string[] allFiles = Directory.GetFiles(dirScanner, "*.cs");

txtCode.Text = "";

foreach (string file in allFiles)
{
string[] lines = File.ReadAllLines(file);


Collection<string> txtStr = new Collection<string>(lines);


var query = txtStr.Where(t => t.Contains("DateTime.Now"));
foreach (string qry in query)
{
txtCode.Text = txtCode.Text + ">>> " + Path.GetFileName(file) + Environment.NewLine;
txtCode.Text = txtCode.Text + qry + Environment.NewLine;
txtCode.Text = txtCode.Text + "-----------" + Environment.NewLine;
}
}
}
string dirScanner = (GlobalVar.dataPath);
if (string.IsNullOrWhiteSpace("DateTime.Now"))
return;

string[] allFiles = Directory.GetFiles(dirScanner, "*.cs");

txtCode.Text = "";

foreach (string file in allFiles)
{
string[] lines = File.ReadAllLines(file);


Collection<string> txtStr = new Collection<string>(lines);


var query = txtStr.Where(t => t.Contains("DateTime.Now"));
foreach (string qry in query)
{
txtCode.Text = txtCode.Text + ">>> " + Path.GetFileName(file) + Environment.NewLine;
txtCode.Text = txtCode.Text + qry + Environment.NewLine;
txtCode.Text = txtCode.Text + "-----------" + Environment.NewLine;
}
}
}
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
This is older code. I will post the lastest
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
Its just from a file that stores all kinds of code I may use in the future. My app is just a place to store code snippets.
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
I did try this but was told it wouldn't work. //string occurrence = lines.Where(l => l.Contains("DateTime.Now")); I will try again with your suggestion.
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
I am searching through every file in a folder with a specific search term. I have the list of all text in each file. But I am stuck on how to filter just the search term and list them the way they are in the file on each line.... and output to a TextBox
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
A file as dicussed above
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
.... Did some research... is this correct for converting??? I get no errors.... But, of course does return any results because I don't have my search term in there anymore. Just need to figure that out.
Collection<string> txtStr = new Collection<string>(lines);
Collection<string> txtStr = new Collection<string>(lines);
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
So, my current struggle is. I have a list from a file..... string[] lines = File.ReadAllLines(file); But, I can't seem to figure out how to convert so I can use it with the IEnumarable Where method that was suggested to me. 1) How do I link my "lines" to this List to get rid of error. Basically how do I convert "lines" to work as a Collection String List<string> txtStr = lines; <<--- ERROR 2) Where do I use my search term? I had to discard it because the entire Where line above was broke and didn't work in my last code. DateTime.Now Thanks for any input.
110 replies
CC#
Created by Pixel-ink on 6/18/2023 in #help
❔ [RESOLVED] Find all Occurrences in All Files in Folder Issue
110 replies