Question

This is hopefully very simple one and I think it lies in the encoding.

I have a string which contains \n for new lines

public ActionResult DownloadText(int id)
{
    var text = "BB2B-XX2A-F2CR-2MMQ-K79A\n3AP2-PH3H-M2QE-2DRH-D73A\nGPD3-AU3Q-P2DN-2FEX-P86A";
    return File(new System.Text.ASCIIEncoding().GetBytes(tempKeys.ToString()), "text/plain", "Key"+ id.ToString() + ".txt");

}

I would like to display each item on a different line when output in the text file.

BB2B-XX2A-F2CR-2MMQ-K79A

3AP2-PH3H-M2QE-2DRH-D73A

GPD3-AU3Q-P2DN-2FEX-P86A

Was it helpful?

Solution

So change the \n to the newline sequence you want. Probably the easiest way, assuming that your text is a string, is:

text = text.Replace("\n", Environment.Newline);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top