标签:
xmlDoc.Save(xmlSavePath); FileStream fileStream = new FileStream(xmlSavePath, FileMode.Open); long fileSize = fileStream.Length; byte[] fileBuffer = new byte[fileSize]; fileStream.Read(fileBuffer, 0, (int)fileSize); //如果不写fileStream.Close()语句,用户在下载过程中选择取消,将不能再次下载 fileStream.Close(); Context.Response.ContentType = "application/octet-stream"; Context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xml", Encoding.UTF8)); Context.Response.AddHeader("Content-Length", fileSize.ToString()); Context.Response.BinaryWrite(fileBuffer); Context.Response.End(); Context.Response.Close();
标签:
原文地址:http://www.cnblogs.com/colin2011/p/4538965.html