Controller.File 方法

定義

多載

File(Byte[], String)

使用檔案內容和檔案類型建立 FileContentResult 物件。

File(Stream, String)

使用串流物件和內容類型建立 FileStreamResult 物件。

File(String, String)

使用檔案名稱和內容類型建立 FilePathResult 物件。

File(Byte[], String, String)

使用檔案內容、檔案類型和目的檔案名稱,建立 FileContentResult 物件。

File(Stream, String, String)

使用 FileStreamResult 物件、內容類型和目標檔案名稱,建立串流物件。

File(String, String, String)

使用檔案名稱、檔案內容和檔案下載名稱,建立 FilePathResult 物件。

File(Byte[], String)

使用檔案內容和檔案類型建立 FileContentResult 物件。

protected internal System.Web.Mvc.FileContentResult File (byte[] fileContents, string contentType);
member this.File : byte[] * string -> System.Web.Mvc.FileContentResult
Protected Friend Function File (fileContents As Byte(), contentType As String) As FileContentResult

參數

fileContents
Byte[]

要傳送至回應的二進位內容。

contentType
String

內容類型 (MIME 類型)。

傳回

檔案內容結果物件。

適用於

File(Stream, String)

使用串流物件和內容類型建立 FileStreamResult 物件。

protected internal System.Web.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType);
member this.File : System.IO.Stream * string -> System.Web.Mvc.FileStreamResult
Protected Friend Function File (fileStream As Stream, contentType As String) As FileStreamResult

參數

fileStream
Stream

要傳送至回應的資料流。

contentType
String

內容類型 (MIME 類型)。

傳回

檔案內容結果物件。

適用於

File(String, String)

使用檔案名稱和內容類型建立 FilePathResult 物件。

protected internal System.Web.Mvc.FilePathResult File (string fileName, string contentType);
member this.File : string * string -> System.Web.Mvc.FilePathResult
Protected Friend Function File (fileName As String, contentType As String) As FilePathResult

參數

fileName
String

要傳送至回應之檔案的路徑。

contentType
String

內容類型 (MIME 類型)。

傳回

檔案資料流結果物件。

適用於

File(Byte[], String, String)

使用檔案內容、檔案類型和目的檔案名稱,建立 FileContentResult 物件。

protected internal virtual System.Web.Mvc.FileContentResult File (byte[] fileContents, string contentType, string fileDownloadName);
abstract member File : byte[] * string * string -> System.Web.Mvc.FileContentResult
override this.File : byte[] * string * string -> System.Web.Mvc.FileContentResult
Protected Friend Overridable Function File (fileContents As Byte(), contentType As String, fileDownloadName As String) As FileContentResult

參數

fileContents
Byte[]

要傳送至回應的二進位內容。

contentType
String

內容類型 (MIME 類型)。

fileDownloadName
String

要在檔案下載對話方塊中使用的檔名,這個對話方塊是在瀏覽器中顯示。

傳回

檔案內容結果物件。

適用於

File(Stream, String, String)

使用 FileStreamResult 物件、內容類型和目標檔案名稱,建立串流物件。

protected internal virtual System.Web.Mvc.FileStreamResult File (System.IO.Stream fileStream, string contentType, string fileDownloadName);
abstract member File : System.IO.Stream * string * string -> System.Web.Mvc.FileStreamResult
override this.File : System.IO.Stream * string * string -> System.Web.Mvc.FileStreamResult
Protected Friend Overridable Function File (fileStream As Stream, contentType As String, fileDownloadName As String) As FileStreamResult

參數

fileStream
Stream

要傳送至回應的資料流。

contentType
String

內容類型 (MIME 類型)

fileDownloadName
String

要在檔案下載對話方塊中使用的檔名,這個對話方塊是在瀏覽器中顯示。

傳回

檔案資料流結果物件。

適用於

File(String, String, String)

使用檔案名稱、檔案內容和檔案下載名稱,建立 FilePathResult 物件。

protected internal virtual System.Web.Mvc.FilePathResult File (string fileName, string contentType, string fileDownloadName);
abstract member File : string * string * string -> System.Web.Mvc.FilePathResult
override this.File : string * string * string -> System.Web.Mvc.FilePathResult
Protected Friend Overridable Function File (fileName As String, contentType As String, fileDownloadName As String) As FilePathResult

參數

fileName
String

要傳送至回應之檔案的路徑。

contentType
String

內容類型 (MIME 類型)。

fileDownloadName
String

要在檔案下載對話方塊中使用的檔名,這個對話方塊是在瀏覽器中顯示。

傳回

檔案資料流結果物件。

適用於