0
my code brings inside a checklistbox the contents of a txt file. Each line of that file (it is also a line in my checklistbox) is the contents of a variable that I will exchange in a Word document. I need that when selecting in my checklistbox the (name of the collaborator) it brings to me from within the txt file only the line of the collaborator I selected for me to store in my variable that will give the replace in Word. Follow code where I read all the lines and assign my strings I need to manipulate their content to bring only 'selected''.
Preencherreplace c = new Preencherreplace();
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];
Okay, buddy, in this same program I’m swapping out some variables from the Word(.docx) document and then printing. However due to my 'Object template' allow to be setting only one file it does not take another that I have selected in my checklistbox if not this, you would know a way to pass the other files of mine to be my choice which to use ? @Rovann Linhalis
– Lucão
@Lucão also performs the exchange of variables within the word. But for this I do in a separate function and save the file in a temporary folder for this. The stream is: Save the temporary file. I call the function that changes the variables, and saves the file. Calls the function that prints. In its context, just put it inside the loop.
– Rovann Linhalis
could explain me better how you do to pass over a Word file to me to verify which ones selected through code?
– Lucão
i don’t pass over a file in function or wordApp. I loop calling one file at a time
– Rovann Linhalis
friends need also in this same program the following, I already have the contents of a txt file read, now I need to bring the line of the txt file that I selected in my checklistbox to change in a variable someone can help me with this link?
– Lucão
edit the question, explaining in detail what you need to do, and I will change the answer by putting what you need.
– Rovann Linhalis
but those files he passes one at a time, how does he identify the path where those files are ? @Rovann Linhalis
– Lucão
i save the files I need, and store the name in variable. then loop to print
– Rovann Linhalis
got it, as for the link with txt I’ll change the question, you can help me ?
– Lucão
yes, I just need to understand what you need to do rs. Try to explain the program requirement and what you are trying to do
– Rovann Linhalis