Name
WriteFile
Synopsis
Response.WriteFile(ByVal fileName As String) Response.WriteFile(ByVal fileName As String, _ ByVal includeHeaders As Boolean) Response.WriteFile(ByVal fileHandle As IntPtr, _ ByVal offset As Long, ByVal size As Long) Response.WriteFile(ByVal fileName As String, _ ByVal offset As Long, ByVal size As Long)
Write s a file specified in one of the overloaded arguments to the output stream.
Parameters
-
fileName A String argument containing the path and filename of the file whose content should be written to the output stream.
-
includeHeaders A Boolean argument indicating whether the contents of the file should be written to a memory block.
-
fileHandle An Argument of type IntPtr containing a handle to a file. You can get the handle by creating a new FileStream object from the file and then querying the FileStream’s Handle property.
-
offset An Argument of type Long containing the byte position in the file from which writing should start.
-
size An Argument of type Long containing the number of bytes that should be written to the output stream.
Example
The example writes the contents of the file dep.txt to the output stream of the current response.
Sub Page_Load( )
Response.WriteFile("dep.txt")
End SubNotes
The WriteFile method can be used in a variety of ways to output text content directly from a file. Attempts to write other content types (such as image data) will fail.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access