How to implement file download in .NET

xiaoxiao2021-03-06  79

FILESTREAM FS = New FileStream ("D: //11.xml", filemode.open; // Byte [] buffer = new byte [(int) fs.length]; // fs.read (buffer, 0, INT) fs.lend (// fs.close (); // // Download file // page.response.addheader ("content-type", "Application / OcT-stream"); ​​// Response.charset = "GB2312"; // response.buffer = true; // httpContext.current.response.appendheader ("Content-Disposition", "Attachment; FileName =" httputility.urlencode (("11.xml")); Response .OutputStream.Write (buffer, 0, buffer.Length); // Response.OutputStream.BeginWrite (buffer, 0, buffer.Length, new AsyncCallback (this.MyCallBack), Response.OutputStream); pCi = CommonFactory.CreateInstance (CommonData . SQL); // pci.begintrans (); // pci = comMonFactory.createInstance (commondata.sql); // pci.close (); // pci.committrans (); pci = pci = CommonFactory.createInstance (Commondata) . SQL); pci.close (); pci.close (); pci.destory ();

} Private void mycallback (IASYNCRESULT AR) {NetWorkStream Str = (NetworkStream) ar.asyncState; httpContext.current.Response.clearheaders (); str.Endwrite (ar);

}

转载请注明原文地址:https://www.9cbs.com/read-121851.html

New Post(0)