private void Button1_Click(object sender, System.EventArgs e)
{
this.Export("1.aaaaaaaaaaaaaaaaa;<bR> 2.bbbbbbbbbbbb;",Response);
}
public void Export(string html,System.Web.HttpResponse response)
{
string time = DateTime.Now.ToString("yyyyMMddHHmmss");
time += DateTime.Now.Millisecond.ToString();
string tmpPath = Server.MapPath("/")+System.Configuration.ConfigurationSettings.AppSettings["ExcelDir"];
if( !Directory.Exists(tmpPath))
Directory.CreateDirectory(tmpPath);
string path = tmpPath + "\\" + time + ".doc";
StreamWriter sr = new StreamWriter(path,false,System.Text.Encoding.BigEndianUnicode);
sr.WriteLine(html);
sr.Close();
response.Clear();
FileStream objStream = File.Open(path,System.IO.FileMode.Open);
long fileSize = objStream.Length;
BinaryReader reader = new BinaryReader(objStream);
reader.GetType();
response.AppendHeader("Content-Disposition","attachment; filename=" + HttpUtility.UrlPathEncode(time+".doc"));
response.AppendHeader("Content-Length",fileSize.ToString());
response.ContentType = "application/vnd.ms-word";
response.Charset="utf-8";
while(reader.PeekChar()>=0)
{
response.BinaryWrite(reader.ReadBytes((int)fileSize));
}
reader.Close();
objStream.Close();
response.Flush();
response.Clear();
response.End();
}