Share via


Controller.File Method

Include Protected Members
Include Inherited Members

Creates a FileContentResult object.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

Overload List

  Name Description
Protected method File(Byte[], String) Creates a FileContentResult object by using the file contents and file type.
Protected method File(Stream, String) Creates a FileStreamResult object by using the Stream object and content type.
Protected method File(String, String) Creates a FilePathResult object by using the file name and the content type.
Protected method File(Byte[], String, String) Creates a FileContentResult object by using the file contents, content type, and the destination file name.
Protected method File(Stream, String, String) Creates a FileStreamResult object using the Stream object, the content type, and the target file name.
Protected method File(String, String, String) Creates a FilePathResult object by using the file name, the content type, and the file download name.

Top

Remarks

The File() helper method provides support for returning the contents of a file. The MediaTypeNames class can be used to get the MIME type for a specific file name extension.

Examples

A Visual Studio project with source code is available to accompany this topic: Download.

See Also

Reference

Controller Class

System.Web.Mvc Namespace