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".
People who read this tip also read these tips:
Look for similar tips by subject:
|