Share via


HttpPostedFile.ContentType 屬性

定義

取得用戶端所送出檔案的 MIME 內容類型。

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

屬性值

String

上載檔案的 MIME 內容類型。

範例

下列程式碼範例示範如何在上傳的檔案集合中迴圈執行所有檔案,並在檔案的 MIME 類型為 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

適用於

另請參閱