HttpFileCollection.Item[] 屬性

定義

從集合中取得指定的 HttpPostedFile 物件。 這個屬性被多載,以允許用名稱或數值索引來擷取 Cookie。

多載

Item[Int32]

以指定的數值索引從 HttpFileCollection 取得物件。

Item[String]

以指定的名稱從檔案集合取得物件。

Item[Int32]

以指定的數值索引從 HttpFileCollection 取得物件。

public:
 property System::Web::HttpPostedFile ^ default[int] { System::Web::HttpPostedFile ^ get(int index); };
public System.Web.HttpPostedFile this[int index] { get; }
member this.Item(int) : System.Web.HttpPostedFile
Default Public ReadOnly Property Item(index As Integer) As HttpPostedFile

參數

index
Int32

要從檔案集合中取得的項目索引。

屬性值

HttpPostedFile

HttpPostedFile 指定的 index

範例

下列範例會從用戶端所傳送的集合擷取第一個檔案物件, (index = 0) ,並擷取物件所代表的實際檔案名。

HttpPostedFile MyPostedMember = Request.Files[0];
 String MyFileName = MyPostedMember.FileName;
Dim MyPostedMember As HttpPostedFile = Request.Files(0)
 Dim MyFileName As String = MyPostedMember.FileName

另請參閱

適用於

Item[String]

以指定的名稱從檔案集合取得物件。

public:
 property System::Web::HttpPostedFile ^ default[System::String ^] { System::Web::HttpPostedFile ^ get(System::String ^ name); };
public System.Web.HttpPostedFile this[string name] { get; }
member this.Item(string) : System.Web.HttpPostedFile
Default Public ReadOnly Property Item(name As String) As HttpPostedFile

參數

name
String

要被傳回的項目名稱。

屬性值

HttpPostedFile

HttpPostedFile 指定的 name

範例

下列範例會從用戶端所傳送的集合擷取名為 「CustInfo」 的檔案物件,並擷取物件所代表的實際檔案名。

HttpPostedFile MyPostedMember = Request.Files["CustInfo"];
 String MyFileName = MyPostedMember.FileName;
Dim MyPostedMember As HttpPostedFile = Request.Files("CustInfo")
 Dim MyFileName As String = MyPostedMember.FileName

另請參閱

適用於