November 06, 2000 - Finding a File's Type | WebReference

November 06, 2000 - Finding a File's Type

Yehuda Shiran November 06, 2000
Finding a File's Type
Tips: November 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Before manipulating a file, you usually need to know its type. To find a file's type, use the Type property. Here is a script that prints the file type:

<SCRIPT LANGUAGE="JavaScript">
<!--
  myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
  file = myActiveXObject.GetFile("f:\\yehuda\test.txt");
  alert(file.Type);
// -->
</SCRIPT>

Here is the popout windows that you'll get for three different types of files:

Notice that the file type is identical to what is shown by the Properties tab when you right click the file icon.