My code brings the content of a txt file inside a checklistbox. Each line of this file (it's also a line in my checklistbox) is the contents of a variable that I'll swap in a Word document. I need that when selecting in my checklistbox the (name of the collaborator) he brings me from within the txt file only the line of the collaborator that I selected for me to store in my variable that will give replace in Word. Here is the code where I read all the rows and assign my strings I need to manipulate the contents of them to bring only the 'selected'.
FillReplace c = new FillReplace ();
string filePath = @"C:\Teste\Lista_col.txt";
string line;
string[] array = File.ReadAllLines(@"C:\Teste\Lista_col.txt");
if (File.Exists(filePath))
{
using (StreamReader reader = new StreamReader(filePath))
{
while ((line = reader.ReadLine()) != null)
{
string[] auxiliar = line.Split(';'); // faço um split separando onde possui barras e virgulas
c.codigo = auxiliar[0];
c.nome = auxiliar[1];
c.funcao = auxiliar[2];
c.setor = auxiliar[3];