日期:2014-05-17 浏览次数:20632 次
FileStream fileStream = new FileStream(@"c:\123.ini", FileMode.Open); long fileSize = fileStream.Length; Context.Response.ContentType = "application/octet-stream"; Context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + HttpUtility.UrlEncode("ini.ini", System.Text.Encoding.UTF8) + "\""); Context.Response.AddHeader("Content-Length", fileSize.ToString()); byte[] fileBuffer = new byte[fileSize]; fileStream.Read(fileBuffer, 0, (int)fileSize); fileStream.Close(); Context.Response.BinaryWrite(fileBuffer); Context.Response.End();