November 11, 2000 - Deleting a File | WebReference

November 11, 2000 - Deleting a File

Yehuda Shiran November 11, 2000
Deleting a File
Tips: November 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

To delete a file, use the delete() method of the File object. Here is a piece of script that will delete a given file:

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

Notice that the File object's methods are case sensitive. Failing to specify "Delete" instead of "delete" will result in a JavaScript error. Also, after you delete a file, any attempts to delete it again will result in a JavaScript error: "No File Found".