What's going on here? Check my previous post.
Here's how to do it without actually creating a file. Thanks to Bogo for pointing me to the memorystream.
private void Page_Load(object sender, System.EventArgs e)
{
System.IO.MemoryStream mStream = new System.IO.MemoryStream();
System.IO.StreamWriter writer =
new System.IO.StreamWriter(mStream);
writer.AutoFlush =
true;
writer.WriteLine("BEGIN:VCALENDAR");
writer.WriteLine(@"PRODID:-//Microsoft Corporation//Outlook MIMEDIR//EN");
writer.WriteLine("VERSION:1.0");
writer.WriteLine("BEGIN:VEVENT");
//Fill in data
DateTime dueDate;
dueDate = DateTime.Parse(maintenance.DueDate);
writer.WriteLine("DTSTART:" + dueDate.Year.ToString() + dueDate.Month.ToString() + dueDate.Day.ToString() + "T170000Z");
writer.WriteLine("DTEND:" + dueDate.Year.ToString() + dueDate.Month.ToString() + dueDate.Day.ToString() + "T170000Z");
writer.WriteLine("LOCATION:" + asset.Site.SiteDescription + " - " + asset.Location.LocationDescription + " - " + asset.Room.RoomDescription);
writer.WriteLine("CATEGORIES:Maintenance");
writer.WriteLine("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + maintenance.MaintenanceDescription + "=0D=0A");
writer.WriteLine("SUMMARY:" + asset.Product.ShortDescription + " Maintenance");
writer.WriteLine("PRIORITY:3");
writer.WriteLine("END:VEVENT");
writer.WriteLine("END:VCALENDAR");
Response.Clear();
// clear the current output content from the buffer
Response.AppendHeader("Content-Disposition", "attachment; filename=Maintenance.vcs");
Response.AppendHeader("Content-Length", mStream.Length.ToString());
Response.ContentType = "application/download";
Response.BinaryWrite(mStream.ToArray());
Response.End();
}