HttpResponse.TransmitFile 方法

定義

將指定的檔案直接寫入 HTTP 回應輸出資料流,而不在記憶體中緩衝。Writes the specified file directly to an HTTP response output stream without buffering it in memory.

多載

TransmitFile(String, Int64, Int64)

將指定的檔案部分直接寫入 HTTP 回應輸出資料流,而不在記憶體中緩衝。Writes the specified part of a file directly to an HTTP response output stream without buffering it in memory.

TransmitFile(String)

將指定的檔案直接寫入 HTTP 回應輸出資料流,而不在記憶體中緩衝。Writes the specified file directly to an HTTP response output stream, without buffering it in memory.

TransmitFile(String, Int64, Int64)

將指定的檔案部分直接寫入 HTTP 回應輸出資料流,而不在記憶體中緩衝。Writes the specified part of a file directly to an HTTP response output stream without buffering it in memory.

public:
 void TransmitFile(System::String ^ filename, long offset, long length);
public void TransmitFile (string filename, long offset, long length);
member this.TransmitFile : string * int64 * int64 -> unit
Public Sub TransmitFile (filename As String, offset As Long, length As Long)

參數

filename
String

要寫入 HTTP 輸出的檔案名稱。The name of the file to write to the HTTP output.

offset
Int64

開始寫入 HTTP 輸出的檔案位置。The position in the file to begin to write to the HTTP output.

length
Int64

要傳送的位元組數目。The number of bytes to be transmitted.

例外狀況

offset 參數小於零。The offset parameter is less than zero.

-或--or- length 參數小於 -1。The length parameter is less than -1.

-或--or- length 參數指定大於檔案包含之位元組數目減去位移的位元組數目。The length parameter specifies a number of bytes that is greater than the number of bytes the file contains minus the offset.

不支援跨處理序 (Out-Of-Process) 背景工作要求。The out-of-process worker request is not supported.

-或--or- 回應並未使用 HttpWriter 物件。The response is not using an HttpWriter object.

offset 參數小於零或大於檔案大小。The offset parameter is less than zero or greater than the file size.

-或--or- length 參數小於 1,或大於 offset 參數加上檔案大小的值。The length parameter is less than -1 or greater than the value of the offset parameter plus the file size.

備註

如果您將 0 offset指定為參數,並將-1 指定length為參數,則會傳送整個檔案。If you specify 0 as the offset parameter and -1 as the length parameter, the whole file is sent.

TransmitFile(String)

將指定的檔案直接寫入 HTTP 回應輸出資料流,而不在記憶體中緩衝。Writes the specified file directly to an HTTP response output stream, without buffering it in memory.

public:
 void TransmitFile(System::String ^ filename);
public void TransmitFile (string filename);
member this.TransmitFile : string -> unit
Public Sub TransmitFile (filename As String)

參數

filename
String

要寫入 HTTP 輸出的檔案名稱。The name of the file to write to the HTTP output.

例外狀況

filename 參數為 nullThe filename parameter is null

適用於