标签:ring odi str efault coding ons files close read
string savapath = Server.MapPath("/haha/" + path);
//创建文件流并打开文件
FileStream fs = new FileStream(savapath,FileMode.Open);
//创建字节数组
byte[] bt = new byte[(int)fs.Length];
//流读取字节数组
fs.Read(bt, 0, bt.Length);
//释放资源
fs.Close();
Response.Charset = "UTF-8";
Response.ContentEncoding = Encoding.Default;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=" + savapath);
Response.BinaryWrite(bt);
Response.Flush();
Response.End();
标签:ring odi str efault coding ons files close read
原文地址:http://www.cnblogs.com/w-pengchao/p/7840509.html