Scripting the File System, Part I: The File Object - Doc JavaScript | WebReference

Scripting the File System, Part I: The File Object - Doc JavaScript


Scripting the File System, Part I

The file Object

GetFile(pathName)Object

This method returns the file object of the given file name. The following script should create a file object for f:\yehuda\js\tips\myapps.txt:

<SCRIPT LANGUAGE="JavaScript">
<!--
var fso = new ActiveXObject("Scripting.FileSystemObject");
fileObj = fso.GetFile("f:\\yehuda\\js\\tips\\myapp.txt");
-->
</SCRIPT>

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
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

Next: How to use GetFolder()

https://www.internet.com


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: November 20, 2000
Revised: November 20, 2000

URL: https://www.webreference.com/js/column71/8.html