Gets the MIME content type of a file sent by a client.
Public ReadOnly Property ContentType As String
Dim instance As HttpPostedFile Dim value As String value = instance.ContentType
public string ContentType { get; }
public: property String^ ContentType { String^ get (); }
public function get ContentType () : String
The following code example shows how to loop through all the files in the uploaded file collection and take action when the MIME type of a file is US-ASCII.
Dim Loop1 As Integer Dim MyFileCollection As HttpFileCollection = Request.Files For Loop1 = 0 To MyFileCollection.Count - 1 If MyFileCollection(Loop1).ContentType = "video/mpeg" Then '... End If Next Loop1
HttpFileCollection MyFileCollection = Request.Files; for (int Loop1 = 0; Loop1 < MyFileCollection.Count; Loop1++) { if (MyFileCollection[Loop1].ContentType == "video/mpeg") { //... } }
var myFileCollection : HttpFileCollection = Request.Files for(var i=0; i < myFileCollection.Count; i++){ if(myFileCollection[i].ContentType == "video/mpeg"){ //... } }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98