public WriteFile ( string filename, bool readIntoMemory ) : void | ||
filename | string | |
readIntoMemory | bool | |
return | void |
public void WriteFile (string filename, bool readIntoMemory)
{
if (filename == null)
throw new ArgumentNullException ("filename");
string fn = GetNormalizedFileName (filename);
if (readIntoMemory){
using (FileStream fs = File.OpenRead (fn))
WriteFile (fs, 0, fs.Length);
} else {
FileInfo fi = new FileInfo (fn);
output_stream.WriteFile (fn, 0, fi.Length);
}
if (buffer)
return;
output_stream.ApplyFilter (false);
Flush ();
}
public bool ReturnXls(System.Web.HttpResponse resp, string fileName) { System.IO.FileInfo f = new System.IO.FileInfo(fileName); resp.ClearHeaders(); resp.ClearContent(); DialogUtils.SetCookieResponse(resp); resp.HeaderEncoding = System.Text.Encoding.Default; resp.AddHeader("Content-Disposition", "attachment; filename=" + f.Name); resp.AddHeader("Content-Length", f.Length.ToString()); resp.ContentType = "application/octet-stream"; resp.Cache.SetCacheability(HttpCacheability.NoCache); /* * resp.BufferOutput = false; * resp.WriteFile(f.FullName); * resp.Flush(); * resp.End(); */ resp.BufferOutput = true; resp.WriteFile(f.FullName); //resp.End(); return(true); }