HttpPostedFile.ContentType プロパティ
クライアントから送信されたファイルの MIME コンテンツ タイプを取得します。
名前空間: System.Web
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
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 ();
}
/** @property */
public String get_ContentType ()
public function get ContentType () : String
適用できません。
プロパティ値
アップロードされるファイルの MIME コンテンツ タイプ。
使用例
アップロードされたファイル コレクション内のすべてのファイルをループし、ファイルの MIME タイプが 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")
{
//...
}
}
HttpFileCollection myFileCollection = get_Request().get_Files();
for (int loop1 = 0; loop1 < myFileCollection.get_Count(); loop1++) {
if (myFileCollection.get_Item(loop1).get_ContentType().
Equals("video/mpeg")) {
//...
}
}
var myFileCollection : HttpFileCollection = Request.Files
for(var i=0; i < myFileCollection.Count; i++){
if(myFileCollection[i].ContentType == "video/mpeg"){
//...
}
}
プラットフォーム
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
HttpPostedFile クラス
HttpPostedFile メンバ
System.Web 名前空間
FileName
HttpPostedFile.ContentLength プロパティ