HttpPostedFile.ContentType Propiedad

Definición

Obtiene el tipo de contenido MIME de un archivo enviado por un cliente.

public:
 property System::String ^ ContentType { System::String ^ get(); };
public string ContentType { get; }
member this.ContentType : string
Public ReadOnly Property ContentType As String

Valor de propiedad

String

Tipo de contenido MIME del archivo cargado.

Ejemplos

En el ejemplo de código siguiente se muestra cómo recorrer en bucle todos los archivos de la colección de archivos cargados y tomar medidas cuando el tipo MIME de un archivo es US-ASCII.

HttpFileCollection MyFileCollection = Request.Files;

 for (int Loop1 = 0; Loop1 < MyFileCollection.Count; Loop1++)
 {
    if (MyFileCollection[Loop1].ContentType == "video/mpeg")
    {
       //...
    }
 }
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

Se aplica a

Consulte también