HttpFileCollection.Get 方法

定義

從檔案集合中回傳一個單一 HttpPostedFile 物件。 此特性被超載,允許透過名稱或數值索引檢索物件。

多載

名稱 Description
Get(Int32)

回傳 HttpPostedFile 檔案集合中指定數值索引的物件。

Get(String)

從檔案集合中回傳指定名稱的 HttpPostedFile 物件。

Get(Int32)

回傳 HttpPostedFile 檔案集合中指定數值索引的物件。

public:
 System::Web::HttpPostedFile ^ Get(int index);
public System.Web.HttpPostedFile Get(int index);
member this.Get : int -> System.Web.HttpPostedFile
Public Function Get (index As Integer) As HttpPostedFile

參數

index
Int32

從檔案集合中回傳的物件索引。

傳回

HttpPostedFile 物件。

範例

以下範例從客戶端傳送的集合中取得第一個檔案物件(index = 0),並取得該物件所代表的檔案名稱。

HttpFileCollection MyFileColl = Request.Files;
 HttpPostedFile MyPostedMember = MyFileColl.Get(0);
 String MyFileName = MyPostedMember.FileName;
Dim MyFileColl As HttpFileCollection = Request.Files
 Dim MyPostedMember As HttpPostedFile = MyFileColl.Get(0)
 Dim MyFileName As String = MyPostedMember.FileName

另請參閱

適用於

Get(String)

從檔案集合中回傳指定名稱的 HttpPostedFile 物件。

public:
 System::Web::HttpPostedFile ^ Get(System::String ^ name);
public System.Web.HttpPostedFile Get(string name);
member this.Get : string -> System.Web.HttpPostedFile
Public Function Get (name As String) As HttpPostedFile

參數

name
String

從檔案集合中回傳的物件名稱。

傳回

HttpPostedFile 物件。

範例

以下範例從用戶端發送的集合中擷取名為「CustInfo」的檔案物件,並取得該物件所代表的實際檔案名稱。

HttpFileCollection MyFileColl = Request.Files;
 HttpPostedFile MyPostedMember = MyFileColl.Get("CustInfo");
 String MyFileName = MyPostedMember.FileName;
Dim MyFileColl As HttpFileCollection = Request.Files
 Dim MyPostedMember As HttpPostedFile = MyFileColl.Get("CustInfo")
 Dim MyFileName As String = MyPostedMember.FileName

另請參閱

適用於