HttpPostedFile.ContentType Proprietà

Definizione

Restituisce il tipo di contenuto MIME di un file inviato da un client.

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

Valore della proprietà

String

Tipo di contenuto MIME del file caricato.

Esempio

Nell'esempio di codice seguente viene illustrato come scorrere tutti i file nella raccolta di file caricati e intervenire quando il tipo MIME di un file è 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

Si applica a

Vedi anche