G
Guest
Hi all,
I'm trying to create a text file on the fly for a user of an ASP.NET
application to download. So far the code I have is:
MemoryStream oStream = null; // using System.IO
string contenttype = "text/plain";
string contentdisposition = "filename=report.txt";
oStream = new MemoryStream();
StreamWriter sw = new StreamWriter(oStream);
Response.Clear();
sw.WriteLine("Hello");
Response.ContentType = contenttype;
Response.Buffer= true;
Response.AddHeader("Content-Disposition", contentdisposition);
Response.BinaryWrite(oStream.ToArray());
Response.End();
However I seem to be getting "empty html" instead. Further, the debugger
shows the memorystream as empty when I call writeline on sw.
Any ideas?
Spammy
I'm trying to create a text file on the fly for a user of an ASP.NET
application to download. So far the code I have is:
MemoryStream oStream = null; // using System.IO
string contenttype = "text/plain";
string contentdisposition = "filename=report.txt";
oStream = new MemoryStream();
StreamWriter sw = new StreamWriter(oStream);
Response.Clear();
sw.WriteLine("Hello");
Response.ContentType = contenttype;
Response.Buffer= true;
Response.AddHeader("Content-Disposition", contentdisposition);
Response.BinaryWrite(oStream.ToArray());
Response.End();
However I seem to be getting "empty html" instead. Further, the debugger
shows the memorystream as empty when I call writeline on sw.
Any ideas?
Spammy