private WriteFile ( FileStream fs, long offset, long size ) : void | ||
fs | FileStream | |
offset | long | |
size | long | |
return | void |
string filePath = @"C:\Downloads\myfile.pdf"; string fileName = "myfile.pdf"; HttpResponse response = HttpContext.Current.Response; response.Clear(); response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); response.ContentType = "application/pdf"; response.WriteFile(filePath); response.End();In this example, the WriteFile method is used to download a PDF file located at `C:\Downloads\myfile.pdf`. The file is sent to the client with the filename specified as `myfile.pdf`. The System.Web namespace is part of the .NET Framework and is included in the `System.Web` assembly.
private WriteFile ( FileStream fs, long offset, long size ) : void | ||
fs | FileStream | |
offset | long | |
size | long | |
return | void |