Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stream Text File

Status
Not open for further replies.

Slonoma

Programmer
Jul 10, 2003
41
US
Hi all.
For a C# webapp, I'm having a hard time streaming a text file. Heres my code:

DateTime fileDate = (DateTime) Session["ExportFileDate"];

Response.Clear();
Response.Buffer= true;
Response.ContentType = "text/plain";
Response.Charset = "";
this.EnableViewState = false;

ArrayList list = Orders.ListOrdersByDate(fileDate);
string file = GenerateOrderFile(list);

Response.Write(file.ToString());
Response.End();

It works great, except instead of creating a file to be saved as text, when the file opens it defaults to file.aspx. It is still a text file, but I would much rather it have the default Save As be a .txt file and not have the user have to change to Save As (All Files) and then have to manually type the .txt. Is there a a quick way to do this?

Thanks,
Slo-No


The trouble with programmers is that they get high on their own supply. -Dimandja
 
Someone should shoot me for trying to answer this question, but have you setup a mime type for the txt extension "text/plain" mime type in IIS? This may solve your problem or perhaps you have aspx set as for the text/plain mime type?
 
I would think that the default setting for .txt in IIS would be notepad.

I went ahead and added it anyway, but to no avail.

Thanks for the suggestion though.
Slo-No

The trouble with programmers is that they get high on their own supply. -Dimandja
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top