1.可以读取文件,将文件在页面显示。
复制
保存
<table> <tr> <td style="width: 100px"><% Response.WriteFile("HTMLPage.htm"); %></td> </tr> </table>
2.读取文件做下载功能:
复制
保存
private void downloadfile(string fname)
{
if (fname == null || fname.trim() == "")
return;
fileinfo file = new fileinfo(fname);
response.clear();
response.addheader("content-disposition",
"attachment; filename=" + httputility.urlencode((file.name), system.text.encoding.utf8));
response.addheader("content-length", file.length.tostring());
response.contenttype = "application/octet-stream";
response.writefile(file.fullname);
response.flush();
response.close();
response.end();
}