System.Web Namespace HttpResponse Class
Writes the specified file directly to an HTTP content output stream.
[ VB ]
Overloads Public Sub WriteFile ( _
ByVal fileHandle As IntPtr, _
ByVal offset As Long, _
ByVal size As Long _
)
[ C# ]
public void WriteFile (
IntPtr fileHandle,
long offset,
long size
);
[ C++ ]
public: void WriteFile (
IntPtr fileHandle,
__int64 offset,
__int64 size
);
[ JScript ]
public function WriteFile (
fileHandle : IntPtr,
offset : long,
size : long
);
- fileHandle
- The file handle of the file to write to the HTTP output stream.
- offset
- The byte position in the file where writing will start.
- size
- The number of bytes to write to the output stream.
The following example writes the entire contents of a text file named "login.txt" ( which might contain literal HTML text and input controls ) directly to the output stream.
String FileName;
FileStream MyFileStream;
IntPtr FileHandle;
long StartPos = 0, FileSize;
FileName = "c:\\temp\\Login.txt";
MyFileStream = new FileStream ( FileName, FileMode.Open );
FileHandle = MyFileStream.Handle;
FileSize = MyFileStream.Length;
Response.Write ( "<b>Login: </b>" );
Response.Write ( "<input type=text id=user /> " );
Response.Write ( "<input type=submit value=Submit /><br><br>" );
Response.WriteFile ( FileHandle, StartPos, FileSize );
MyFileStream.Close ( );
Dim MyFileStream As FileStream
Dim FileName As String
Dim FileHandle As IntPtr
Dim StartPos As Long = 0, FileSize As Long
FileName = "c:\\temp\\Login.txt"
MyFileStream = New FileStream ( FileName, FileMode.Open )
FileHandle = MyFileStream.Handle
FileSize = MyFileStream.Length
Response.Write ( "<b>Login: </b>" )
Response.Write ( "<input type=text id=user /> " )
Response.Write ( "<input type=submit value=Submit /><br><br>" )
Response.WriteFile ( FileHandle, StartPos, FileSize )
MyFileStream.Close ( ) |
|
C# |
VB |
HttpResponse Members HttpResponse.WriteFile Overload List