HttpFileCollection.Get 方法

定义

从文件集合中返回单个 HttpPostedFile 对象。 此属性重载以允许按名称或数字索引检索对象。

重载

名称 说明
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

另请参阅

适用于