October 20, 2000 - File Operations and Properties | WebReference

October 20, 2000 - File Operations and Properties

Yehuda Shiran October 20, 2000
File Operations and Properties
Tips: October 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

You create an ActiveX File object by calling ActiveXObject() with a single argument, Scripting.FileSystemObject:

myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");

You create a File object by using the ActiveX's GetFile() method:

myFile = myActiveXObject.GetFile("c:\\Autoexec.bat");

Here are the File object's properties:

PropertyDescription
AttributesRefers to the file attributes
DateCreatedReturns the file's creation date
DateLastAccessedReturns the file's last-accessed date
DateLastModifiedReturns the file's last-modified date
DriveReturns the file's letter drive
NameReturns the file name
ParentFolderReturns the file's parent folder name
PathReturns the file's long path
ShortNameReturns the file's short name
ShortPathReturns the file's short path
SizeReturns the file size
TypeReturns the file type

Here are the File object's methods:

MethodDescription
Copy()Copies the file from one folder to another
Delete()Removes the file
Move()Moves the file from one folder to another
OpenAsTextStream()Opens the file as a text stream