System.Web.HttpResponse.WriteFile C# (CSharp) Method

WriteFile() private method

private WriteFile ( FileStream fs, long offset, long size ) : void
fs FileStream
offset long
size long
return void
		internal void WriteFile (FileStream fs, long offset, long size)
		{
			byte [] buffer = new byte [32*1024];

			if (offset != 0)
				fs.Position = offset;

			long remain = size;
			int n;
			while (remain > 0 && (n = fs.Read (buffer, 0, (int) Math.Min (remain, 32*1024))) != 0){
				remain -= n;
				output_stream.Write (buffer, 0, n);
			}
		}
		

Same methods

HttpResponse::WriteFile ( IntPtr fileHandle, long offset, long size ) : void
HttpResponse::WriteFile ( string filename ) : void
HttpResponse::WriteFile ( string filename, bool readIntoMemory ) : void
HttpResponse::WriteFile ( string filename, long offset, long size ) : void

Usage Example

Example #1
0
        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);
        }
All Usage Examples Of System.Web.HttpResponse::WriteFile