HttpFileCollection.Get 方法

定義

從檔案集合中傳回個別 HttpPostedFile 物件。Returns an individual HttpPostedFile object from a file collection. 這個屬性被多載,以允許用名稱或數值索引來擷取 Cookie。This property is overloaded to allow retrieval of objects by either name or numerical index.

多載

Get(Int32)

從檔案集合中取得指定之數值索引的 HttpPostedFile 物件。Returns the HttpPostedFile object with the specified numerical index from the file collection.

Get(String)

從檔案集合中傳回指定之名稱的 HttpPostedFile 物件。Returns the HttpPostedFile object with the specified name from the file collection.

Get(Int32)

從檔案集合中取得指定之數值索引的 HttpPostedFile 物件。Returns the HttpPostedFile object with the specified numerical index from the file collection.

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

要從檔案集合中傳回之物件的索引。The index of the object to be returned from the file collection.

傳回

HttpPostedFile

HttpPostedFile 物件。An HttpPostedFile object.

範例

下列範例會從用戶端所傳送的集合中,抓取 (index = 0) 的第一個檔案物件,並抓取物件所代表的檔案名。The following example retrieves the first file object (index = 0) from the collection sent by the client and retrieves the name of the file represented by the object.

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 物件。Returns the HttpPostedFile object with the specified name from the file collection.

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

要從檔案集合中傳回之物件的名稱。The name of the object to be returned from a file collection.

傳回

HttpPostedFile

HttpPostedFile 物件。An HttpPostedFile object.

範例

下列範例會從用戶端所傳送的集合中取出名為 "CustInfo" 的檔案物件,並抓取物件所代表的實際檔案名。The following example retrieves the file object named "CustInfo" from the collection sent by the client and retrieves the name of the actual file represented by the object.

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
      

另請參閱

適用於