Type

(PWS4 IIS4 IIS5)
Type — ファイルまたはフォルダの種類に関する情報を返します。たとえば、名前が .TXT の拡張子で終わるファイルの場合なら、”テキスト文書” という文字列が返されます。

構文

object.Type

パラメータ

object
File オブジェクトを指定します。

戻り値

ファイルの種類を返します。

説明

ファイルの種類を返します。
[ごみ箱] などの特殊フォルダをプロシージャに指定してみてください。

JScript

1
2
3
4
5
6
7
8
9
10
11
12
13
function ShowFileType(filespec)
{
   var fso, f, s;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   if (fso.FolderExists(filespec))
      f = fso.GetFolder(filespec);
   else if (fso.FileExists(filespec))
      f = fso.GetFile(filespec);
   else
      s = "ファイルまたはフォルダが存在しません。";
   s = f.Name + " は、" + f.Type + " です。";
   return(s);
}

VBScript

1
2
3
4
5
6
7
Function ShowFolderType(filespec)
   Dim fso, f, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder(filespec)
   s = UCase(f.Name) & " は、" & f.Type & " です。"
   ShowFolderType = s
End Function