HttpFileCollection.Get 方法

定義

從檔案集合中傳回個別 HttpPostedFile 物件。 這個屬性被多載,以允許用名稱或數值索引來擷取 Cookie。

多載

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

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

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

另請參閱

適用於