Friends, I'm trying to generate a txt, in which the user clicks the button and automatically downloads it. You are already generating txt, but would you like to know how to write it?
string str = "testando";
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0,bytes.Length);
MemoryStream mem = new MemoryStream();
mem.Write(bytes, 0, str.Length);
Stream outStream = Response.OutputStream;
Response.ContentType = "application/text/plain";
Response.AppendHeader("Connection", "keep-alive");
Response.AppendHeader("Content-Disposition","attachment; filename = " + "teste.txt");
mem.WriteTo(outStream);
outStream.Close();