語言

HttpFileCollection.Item[] 屬性

定義

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

多載

名稱 Description
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

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

屬性值

由 HttpPostedFileindex指定 。

範例

以下範例從用戶端傳送的集合中取得第一個檔案物件(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

要歸還的物品名稱。

屬性值

由 HttpPostedFilename指定 。

範例

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

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

另請參閱

適用於