1. Pay special attention to the use of JS files and the aspx file character set.
Under normal circumstances, Asp.net may have character set problems when handling a JS file. Because JS usually adopts the ASCII code method, the Asp.net page is usually UTF-8 or Unicode, so the two sessions suddenly rushed, so pay special attention to it!
2.The memory occupied by Asp.net files is too large.
Use
Fileinfo = new fileinfo (filepath );
Response. Clear ();
Response. clearcontent ();
Response. clearheaders ();
Response. addheader ("content-disposition", "attachment; filename =" +
Filename );
.......
Directly open the file and send the file. This will occupy a lot of memory. The following two methods can be used to alleviate the problem:
The following code controls the buffer size? 1024 bytes should be too small
Byte [] buffer1 = new byte [0x400];
While (num3> 0)
{
Num3 = stream1.read (buffer1, 0, buffer1.length );
Response. outputstream. Write (buffer1, 0, num3 );
}
Try this.
Private void downfile (string filepath, string filename)
{
Fileinfo = new fileinfo (filepath );
Response. Clear ();
Response. clearcontent ();
Response. clearheaders ();
Response. addheader ("content-disposition", "attachment; filename =" +
Filename );
Response. addheader ("Content-Length", fileinfo. length. tostring ());
Response. addheader ("content-transfer-encoding", "binary ");
Response. contenttype = "application/octet-stream ";
Response. contentencoding = system. Text. encoding. getencoding ("gb2312 ");
Response. writefile (fileinfo. fullname );
Response. Flush ();
Response. End ();
From: http://blueleopard.bokee.com/4954120.html