2
Good Afternoon, I am developing a program that reads a certain file (contains more than 60k lines) removes unnecessary use and organizes and writes to another file.
using (StreamReader leitor = new StreamReader(lerArquivo))
{
while (!leitor.EndOfStream)
{
var linha = new ArquivoTxt();
linha.Linha = leitor.ReadLine();
conteudoArquivo.Add(linha);
}
var gravarArquivo = @"C:\log\meutxt.txt";
using (StreamWriter sw = new StreamWriter(gravarArquivo))
{
conteudoArquivo = conteudoArquivo.Where(_ => _.Linha.StartsWith("|") &&
_.Linha.Substring(0, 2) != "|0" &&
_.Linha.Substring(0, 2) != "|-" &&
_.Linha.Substring(0, 2) != "|C" &&
_.Linha.Substring(0, 2) != "|I" &&
_.Linha.Substring(0, 2) != "| " &&
_.Linha.Substring(0, 2) != "|R" &&
_.Linha.Substring(0, 2) != "|D" &&
_.Linha.Substring(0, 2) != "|E").ToList();
foreach (var item in conteudoArquivo)
{
string[] linha = item.Linha.Split('|');
string ordemVenda = linha[1].Trim();
sw.WriteLine(linha[1]);
}
sw.Close();
}
}
only that in return it only returns me the 1st column of the File and I wanted the return of the whole Line
it’s not because you’re just reading the
linha[1]
??– Leandro Angelo
And why do you use the
using
and closes the file? And there is some reason to create variable where you do not need and stop creating where will be very useful?– Maniero
@Leandroangelo I’ve tried to change does not return what I want
– Guilherme Palange
@Maniero I’m starting, I don’t know much yet.
– Guilherme Palange