Export (0) Print
Expand All

HttpResponse.WriteFile Method (String)

Writes the specified file directly to an HTTP response output stream.

Namespace: System.Web
Assembly: System.Web (in system.web.dll)

public void WriteFile (
	string filename
)
public void WriteFile (
	String filename
)
public function WriteFile (
	filename : String
)

Parameters

filename

The name of the file to write to the HTTP output.

When this method is used with large files, calling the method might result in an exception. The size of the file that can be used with this method depends on the hardware configuration of the Web server. For more information, see article 812406, "PRB: Response.WriteFile Cannot Download a Large File" in the Microsoft Knowledge Base.

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.

Response.Write("Please Login: <br>");
 Response.WriteFile("login.txt");
    

get_Response().Write("Please Login: <br>");
get_Response().WriteFile("login.txt");

Response.Write("Please Login: <br>")
Response.WriteFile("login.txt")


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft