How to create a txt file and download?

1

I use the following code to generate a txt file in Windows Forms:

StreamWriter file = new StreamWriter("D:\teste.txt");
List<Producao> bpa = ProducaoDados.BuscarBPAC(txtCompetencia.Text);
foreach (Producao linha in bpa)
    {
    file.WriteLine(
    "02" +
    linha.Unidade +
    linha.Competencia.Substring(3, 4) + linha.Competencia.Substring(0, 2) + //competencia
    linha.Cbo +
    string.Format("{0:000}", linhaTexto) + string.Format("{0:00}", linhaItem) +
    linha.Procedimento +
    "000" +
    string.Format("{0:000000}", linha.Quant) +
    "EXT"
    );

    linhaItem++;
    if (linhaItem > 20)
    {
        linhaItem = 1;
        linhaTexto++;
    }
}

I want to know how to include this code in a MVC project, the system to create this file and at the end, the pro user option to download the same on your machine.

    
asked by anonymous 21.08.2017 / 00:27

0 answers