I am trying to generate a .txt
file from a code list retrieved from the database. However, when the file is generated, line breaks are excessive, as shown below:
Thecodeisasfollows,beingaforeachthattraversestheentirelistofobjectsretrievedfromthedatabaseandwriteseachcodeinthe.txtfile:
using(StreamWriterlinha=System.IO.File.CreateText(caminhoArquivo))foreach(varitemincodigos){linha.Write(item+"\r\n");
}
return File(caminhoArquivo, "text/plain", nomeArquivo);
For line breakage, in addition to "\r\n"
, I've already tried to use line. WriteLine (item) and line. **Write**(item + *Enviroment.NewLine*)
, and other variations. however, the problem persisted.
Does anyone know how to solve it?