FileName Property
Collapse the table of content
Expand the table of content

HttpPostedFile.FileName Property

Gets the fully-qualified name of the file on the client's computer (for example "C:\MyFiles\Test.txt").

[Visual Basic]
Public ReadOnly Property FileName As String
[C#]
public string FileName {get;}
[C++]
public: __property String* get_FileName();
[JScript]
public function get FileName() : String;

Property Value

The name of the client's file.

Example

The following example assigns the name of an uploaded file (the first file in the file collection) to a string variable.

[Visual Basic] 
Dim MyFileColl As HttpFileCollection = Request.Files
 Dim MyPostedFile As HttpPostedFile = MyFileColl.Get(0)
 Dim MyFileName As String = MyPostedFile.FileName
    

[C#] 
HttpFileCollection MyFileColl = Request.Files;
 HttpPostedFile MyPostedFile = MyFileColl.Get(0);
 String MyFileName = MyPostedFile.FileName;
    

[C++] 
HttpFileCollection* MyFileColl = Request->Files;
 HttpPostedFile* MyPostedFile = MyFileColl->Get(0);
 String* MyFileName = MyPostedFile->FileName;
    

[JScript] 
var myFileCollection : HttpFileCollection = Request.Files
var myPostedFile : HttpPostedFile = myFileCollection.Get(0)
var myFileName : String = myPostedFile.FileName

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpPostedFile Class | HttpPostedFile Members | System.Web Namespace

Show:
© 2016 Microsoft