System.Web Namespace HttpResponse Class
Writes the specified file directly to an HTTP content output stream.
[ VB ]
Overloads Public Sub WriteFile ( _
ByVal filename As String _
)
[ C# ]
public void WriteFile (
string filename
);
[ C++ ]
public: void WriteFile (
String* filename
);
[ JScript ]
public function WriteFile (
filename : String
);
- filename
- The name of the file to write to the HTTP output.
The following example writes the entire contents of an .aspx file directly to the output stream.
void Page_Load ( object sender, EventArgs e ) {
// set the appropriate ContentType.
Response.ContentType = "text/plain";
// get the physical path to the file.
string FilePath = Server.MapPath ( "~/shop/index.aspx" );
// write the file directly to the HTTP content output stream.
Response.WriteFile ( FilePath );
Response.End ( );
}
Sub Page_Load ( sender As Object, e As EventArgs )
' set the appropriate ContentType.
Response.ContentType = "text/plain"
' get the physical path to the file.
Dim FilePath As String = Server.MapPath ( "~/shop/index.aspx" )
' write the file directly to the HTTP content output stream.
Response.WriteFile ( FilePath )
Response.End ( )
End Sub |
|
C# |
VB |
Show me
HttpResponse Members HttpResponse.WriteFile Overload List