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
public string FileName {get;}
public: __property String* get_FileName();
public function get FileName() : String;

Property Value

The name of the client's file.


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

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

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

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


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

See Also

HttpPostedFile Class | HttpPostedFile Members | System.Web Namespace

© 2016 Microsoft