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(); }