<p>I have a page in my vb.net web application that needs to toss a bunch of data into a text file and then present it to the user for download.  What's the best / most efficient way to build such a text file on a .net web server?</p>

<p>Edit: to answer a question down below, this is going to be a download once and then throw-away kind of file.</p>

<p>Update: I glued together the suggestions by John Rudy and DavidK, and it worked perfectly.  Thanks, all!</p>

Use a StringBuilder to create the text of the file, and then send it to the user using Content-Disposition.
Example found here:
http://www.eggheadcafe.com/community/aspnet/17/76432/use-the-contentdispositi.aspx
```
```
private void Button1_Click(object sender, System.EventArgs e)
{
        StringBuilder output = new StringBuilder;
        //populate output with the string content
        String fileName = "textfile.txt";

        Response.ContentType = "application/octet-stream";
        Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
        Response.WriteFile(output.ToString());

}
```
```