string[] lines = System.IO.File.ReadAllLines(@"C:\Users\Admin\Desktop\ID.csv");
string sPattern = idBox.Text;
foreach (string s in lines)
{
if (System.Text.RegularExpressions.Regex.IsMatch(s, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
{
nameLabel.Text = "test success";
}
else
{
nameLabel.Text = "test failure";
}
}
This is basically what I have so far. I am using Visual C#, which is probably obvious, but just in case you didn't know.
ID.csv includes:
123456a, 123457b, 123458c
I want to separate the IDs into separate lines, and be able to search within the string.
If someone enters 456, I would like nameLabel.Text to output the entire line from within the string[]. I know i will need line.Split(',') somewhere, I've read that multiple places but am not sure on how to implement it. Also, it always outputs "test failure" to the nameLabel no matter if what i entered was correct or not. Any help would be appreciated.